Monday, March 17, 2008

Resolving ClassNotFoundExceptions

Ever got stuck at a ClassNotFoundException or NoClassDefFoundError exception, and you really didn't know, which jar file you should add in the classpath to resolve this?
Ever came across a situation when you added a new library in the classpath, but your application is failing to pick it up, just because there exists another jar in the classpath which contains an older version of your library, and got loaded before your new one?

In these situations, you will need to identify that jar/zip, which contains a particular class/package structure, and probably add or remove it from the classpath.

There are many ways to do this.

1. You could open each jar/zip in your machine and search for your class/package.
2. Get assistance from search engines like JARHOO or JAVACIO.US to list all the known jars and applications that contains this class, and search for them in your machine.
3. Make use of this small tool to do the job for you.

About ClassFinder

ClassFinder is a small Java application to help developers search for an archive that contains a particular class or a package structure in 3 easy steps.



1. Select the root directory where you want ClassFinder to search for the archive. The application will search all the files and directories under this.


2. Specify if you wish to search a particular class name (Eg: JButton), or a fully qualified class name(Eg: javax.swing.JButton). Type in the classname or the fully qualified class name as per your selection.



3. Specify what type of archive you wish to search in (Eg: jar, war, zip). Currently, you can search only one type of archive at one shot. Click on the Search Button.



4. If there is a match, it will get listed in the list box at the bottom. Same file name listed multiple shows that this archive has multiple classes with the same name(This will happen only of you have opted to search for class name, not a fully qualified class name)



Licence, Download and Installation

ClassFinder is a freeware. ClassFinder can be downloaded here. This is an executable jar file. You need to have Java installed on your PC to run ClassFinder. Double clicking the jar should run it.

Let me know if you come across any issues.

1 comment:

Anonymous said...

Thanks!