A Java Applet needed to be slightly modified in order to alter its basic behavior. However, all we had was its class binary and resource files (images and the sort). Not having any source java files, the only approach would be to de-compile the entire class hierarchy, alter the de-compiled classes, and then re-compile them again to obtain the modified Applet. Besides, it was mandatory to sign the resulting applet to prevent the user from adding a security exception on her Java Control Panel.
I used the Java Decompiler project. After running the jd-gui tool, I could open the entire Applet jar file and store its sources under another directory:
The first thing I tried right after having access to the sources, was to re-compile the entire project to make sure it was still working. However, whilst doing so, I got a trivial namespace error:
relativitat/PanellAnimacio.java:34: package Point2D does not exist
/* */ private Point2D.Double one;
I had to import the class Point2D by adding this trivial line into the PanellAnimacio.java source file:
After adding that line of code, I recompiled the entire directory using the javac compiler with no errors at all. Finally, I made a JAR file containing all the binary classes and external resources (images in this case):
jar cf relativitat.jar relativitat/*.class relativitat/imatges*
The resulting JAR file had everything needed to run the Applet inside a web browser. I wrote a trivial HTML test page to try it out:
<APPLET code="relativitat.jApplet" archive="relativitat.jar" width=982 height=420></APPLET>
It worked fine. So, I made all the small alterations and changes that were required, re-compiling the Applet and re-making the JAR file. So far so good, when it comes to decompiling java applets, JD is a good point to start.