Creating a Project
Now you are ready to create a Java Project in Eclipse:
- Click File -> New -> Project. Choose Java Project and click Next.
- Under Name, type DevxDecompilerTutorial. Choose the location of your project, and create separate source and output folders. Click Next.
- You should now define your Java settings. Click the Libraries tab, and then click Add External JARs. Navigate to where you unzipped your Spring download, and add the spring.jar to your project. Click Finish.
|Figure 3. XmlBeanFactory Class Decompiled|
Search For and Then Decompile a Class
Now try to decompile a class within your project:
- Use the Eclipse shortcut CTRL + SHIFT + T, and type XMLBeanFactory. Press return.
- Your Eclipse editor will focus on a new file, XMLBeanFactory.class, which contains the Java source. At the top of the file, you will see comments the creators of the Jad decompiler made. At the bottom of your file, you will find a decompilation report (see Figure 3).
And that's all there is to it. There are other java decompilers out there (Mocha, WingDis, and Déjà Vu come to mind), but they do not integrate into the IDE. What makes the Jad decompiler so powerful is you can integrate it into your development environment.
What do you stand to gain by integrating the decompiler into your IDE? The decompiler certainly is not a revolutionary tool that will change the way you code; but once you start to use it, you could soon easily find yourself relying on it throughout the working day.
For example, when you search for classes as explained previously in this tutorial, your decompiler is there for you. During debugging, your decompiler will allow you to step into method calls of classes for which you don't have the source. You might even prefer to look at the decompiled class first rather than the javadocs—why read the documentation of a jar or set of packages when you can look at the actual implementation?
DJ Java Decompiler
DJ Java Decompiler is a graphical version of the Jad decompiler tool. At the moment, a plug-in doesn't exist to integrate into the Eclipse IDE, but then there doesn't appear to be a need for one either. I use the DJ Java Decompiler on occasion, when it's not practical to use the Eclipse Jad plug-in. Such cases might be:
- You want to decompile a library or a number of classes and plug them into your source directory to aid development.
- You are sure that you updated your build, but the change you made doesn't appear to be in place. Decompile your build, and see if the change is there.
All in all, the decompiler can be a very handy development tool in your arsenal. I hope you'll find it to be as useful in your development as I have.