views:

29

answers:

1

I was unfortunately forced to result to uploading a WAR file as my backup for a web application I am working on.

Luckily I have the most recent WAR file available. I am using Eclipse IDE and am using the Web Tools plugin for all the J2EE work that I am doing with the Dynamic Web Application Project.

When I imported my WAR file, and ran it on a local server, everything works fine. The problem I a ran into is that in the Java Resources/src folder that all my packages and .java files were now only consists of all the same packages, but they are empty.

I checked to see if I could find the files and I found the .class files in an "Imported files" folder that is not accessible in the Eclipse Project Explorer. I believe that I need to do some type of build or something so that my .java files are available for me, but unfortunately this is one area where I lack.

One thing I would also like to know is, one way or the other, am I able to obtain the .java source code files if I have access to the .class files?

Also, I would like to configure this environment as it was before where my Java Resources:src folder contaiend the packages and .java files.

+2  A: 

One thing I would also like to know is, one way or the other, am I able to obtain the .java source code files if I have access to the .class files?

The short answer is No. There is no way to regenerate original source files from bytecode files.

If you were really, really desperate you could try to use a Java bytecode decompiler on your bytecode files, but the result will be be nothing like your original source code.

  • All comments and javadocs will be gone.
  • All original code layout will be gone.
  • Original local variable and parameter names may be gone, depending on your original compiler switches.
  • Constant expressions may have been pre-evaluated, and loops, string concatenations and other constructs may have been transformed unrecognizably.
  • Depending on the maturity of the decompiler, the Java code might not be semantically equivalent to the original code, and might not even be compilable.

I hope you haven't spent too long developing this application because the best answer may be to start again.

Stephen C
well luckily I dropped a copy of the entired directory of the Eclipse project onto an external hard drive prior to this problem. Am I still good, I checked it and it has copies of the source code. Thanks for all your help Stephen C.
CitadelCSAlum