0

I was asked to make a change to a Java app hosted on Glassfish 3.0. I do not have the source code. Will I be able to obtain the source code by decompiling it, make changes to it, and redeploy it with my changes? Would anyone be able to help?

peterh
  • 11,875
  • 18
  • 85
  • 108
Laurent Rivard
  • 509
  • 4
  • 13

2 Answers2

0

This is going to depend on how your ear/war file was compiled, if it was compiled with the include source option your will be able to obtain the source code.You can import the ear/war file into your IDE(Eclipse/Netbeans).

Christian
  • 739
  • 6
  • 10
0

Extending @ChristianMajuta 's clear answer, I must mention: most java application can be recompiled even if its source code wasn't compiled into its jar/war/ear. What you have to do:

  1. extract the jar/war/ear , extract its components, etc, until you get a big directory containing the .class files.
  2. Look for a java decompilator. It is a software which can decompile .class files to .java source code. Here you can't ask for a software recommendation, but on softwarecs.stackexchange.com it is allowed to do, and google is also your friend.
  3. Decompile the classes to java with it.
  4. Do you intentended modifications.
  5. Compile this again (best if you import your decompiled code into a new eclipse/maven project).

There could be little problems, for example, decompiled java code removes all of the comments and its general lookup will be much worse, but it will work. Fortunately, java is a very easily decompilable language. Good luck!

peterh
  • 11,875
  • 18
  • 85
  • 108