JARClassFinder and Log Watcher Eclipse Plug-ins

 

Eclipse is one of the most widely used IDE for Java-based application development. Its extensibility in the form of plug-ins is a key factor to its popularity among developers across the globe. In this article, we shall study two useful Eclipse plug-ins – JARClassFinder and LogWatcher

Eclipse is available as an Open Source tool. You can download the latest version (see figure 1) from http://www.eclipse.org/downloads/index.php.


Fig 1: Eclipse download page

JARClassFinder

When you compile your project source code, the probability of you may encountering NoClassDefFound exceptions is high. You get this exception because your project build path is missing the required JAR file containing the class that you referenced in your code. Locating the correct JAR file is the only solution to solve this issue. IBM has developed an Eclipse plug-in called JARClassFinder as a solution to the NoClassDefFound issue. You can get the latest version of JARClassFinder Eclipse plug-in (refer figure 2) from http://www.alphaworks.ibm.com/tech/jarclassfinder/download.




Figure 2: JARClassFinder Eclipse Plug-in download page

Installing JARClassFinder is fairly straightforward. First, extract the downloaded zip file on to your system hard disk. Copy com.ibm.wpst.hursley.jarclassfinder_2.0.3 under plugins to your Eclipse plug-ins directory and restart Eclipse. 

If everything goes well, you will now see a new icon in the Eclipse tool bar as shown in figure 3.



Fig 3: JARClassFinder Icon in Eclipse Tool Bar

Now let us see how this JARClassFinder eclipse plug-in helps us solve the NoClassDefFound errors.

Create a new Java project with a source file, shown in figure 4.



Fig 4: Eclipse showing a Project with Class Not Found error

In figure 4, you can see that we have used the log4 classes but have not included the log4j JAR file in the project build path. To include the JAR file in the build path, we need to first locate the JAR file. To find the JAR file, click the JARClassFinder icon and enter the class name and search directory details. Refer figure 5.



Click on Find button to locate the JAR file. You will see a new view for JARClassFinder listing the class file and corresponding JAR file location in Eclipse. See figure 6.



To add JAR file to the project build path, right click on the JARClassFinder view result and select ‘Add To Project Build Path’ menu. Refer figure 7.


Once everything goes well, you can see the success message from JARClassFinder plugin (figure 8). Figure 9 shows the successful addition of log4j JAR file in the Project build path.





LogWatcher
If you have worked on Unix platform, you will be aware of the ‘tail’ utility. One of the most frequently and widely used option with the tail command is ‘-f’. This option instructs the tail utility to reload the file and continue showing if it is modified. This helps users to view the log files in real-time as they get updated by programs.

LogWatcher adds a view to Eclipse that allows log files to be monitored for changes, similar to the Unix tail utility. It is available as an Eclipse plug-in from http://sourceforge.net/projects/graysky.

Installing the LogWatcher plug-in is also fairly simple. Extract the downloaded zip file on to your system hard disk and copy the org.graysky.eclipse.logwatcher_1.4.0.1 to your Eclipse plug-ins directory and restart Eclipse.

To get the LogWatcher view, select LogWatcher under Log Files in Show View window (figure 10).



To create a new watcher, click on the ‘Create a new watcher’ icon in the LogWatcher view and enter the log file details as shown in figure 11.



Fig 11: Creating New Watcher Dialog

Figure 12
illustrates the LogWatcher view showing the log file content in real-time.

 

So you now know how simple it is to solve the NoClassDefFound error using JARClassFinder and view log files for changes in real-time using the LogWatcher eclipse plug-ins! Happy and easier programming!!!

About the author



Raja R.K is a Project Lead working with HCL Technologies (Networking Product Division) in Chennai. He has several years of experience in the Software Development and can be contacted at: rajark_hcl@yahoo.co.in.

References:
Eclipse: www.eclipse.org.
JARClassFinder: www.alphaworks.ibm.com.
LogWatcher: www.sourceforge.net.




Added on June 18, 2007 Comment

Comments

Post a comment