Tuesday, March 11, 2008
on't you hate it when you are debugging your code within Eclipse, and while stepping into a method call, a Class File Editor pops up exclaiming "Source Not Found"? Wouldn't you rather see the Java source the next time that happens? By integrating a Java decompiler into your IDE, you can enable this functionality. Follow this complete step-by-step guide to integrate the Jad decompiler into Eclipse. Along the way, you'll find out what makes Java decompilers such handy additions to the developer's toolkit.
First, you need to download the necessary tools. Before anything else, make sure you have an installation of Eclipse. This article uses Eclipse 3.0.1. Note that in order to use Eclipse 3, you must use a J2SE of 1.4 or higher. This article uses J2SE 5.0 (formerly Tiger).
|Figure 1. Eclipse JadClipse Settings|
Now download the latest version of the Jad Java decompiler. This article uses version 1.5.8 for Windows. Unzip the zip file to your computer:
- Add your JAD_HOME directory to your PATH environment variable. For example, I unzipped my Jad download to C:\jadnt158 and added it to PATH.
- To test whether you have configured correctly, open a new DOS shell. Type 'jad' at the prompt. You should see information about Jad and options for usage.
Next, download the latest version (beta 2.06) of the JadClipse plugin for Eclipse. Unzip the zip file to your computer. Copy the jadclipse folder (not jadclipse_b206) to your Eclipse\plugins folder.
Finally, download the Spring Framework (Spring 1.1.2 was the latest version at the time of this article) and unzip the download to your computer.
|Figure 2. Eclipse Workbench File Associations Settings|
Now configure the JadClipse plugin within Eclipse:
- Open Eclipse. At the top menu, click Window->Preferences->Java->JadClipse.
- Set Path to decompiler = %jadnt158_directory%\jad.exe. Additionally, you can also set the output directory for decompiled files as well (see Figure 1). Click Apply.
- Now expand the Workbench node, and choose File Associations. In the top box named File Types, select *.class. In the bottom box named Associated Editors, select JadClipse Class File Viewer, and click Default (see Figure 2).
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.