Question

I have one War files (a Java application) consist of 64 class file along with image/CSS/JS files. I have lost the source of this war file. Now I want to do some changes in code. I am looking for some expert advice from community on following questions.

  1. Is there best way to convert .class files to .java file without losing any section of code?
  2. What are the tools if any for this task?
  3. What are challenges/drawbacks of converting .class files to .java files to recreate war file?
Was it helpful?

Solution

If you do not want to spend horrible times in understanding decompiled bytecode, please start using a version control system and a remote repository for any project of more than two classes.

In particular, you can use Git with GitHub, open source are hosted for free while if you want to protect your code you can get a commercial subscription which is cheap anyway.

For this time, help yourself with a java decompiler such as JD:

  1. Use a java decompiler to decompile the bytecode.
  2. Create a git repository out of the decompiled java classes
  3. Constantly synchronize it with the remote repository

OTHER TIPS

  1. Conversion to Java Bytecode is almost completely reversible. As @StephenC said, In the regenerated sources, you will lose comments, names of local variables etc. It might not compile right away but you should be able to get it to compile again, with a little modification.

  2. You need a Java Decompiler to do that. Try JD-GUI or DJ Java Decompiler

  3. In case you obfuscated your sources, the sources you recover will not be harder to understand and reverse engineer. Otherwise, with just a little tinkering, you should be able to get back your sources.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top