Java class finding tool: ClassFinder

I got into more coding again lately and that is a good thing I think. I’m a believer of the German saying “Wer rastet, der rostet” or in English: A rolling stone gathers no moss! Java seems to be my main programming language since quite a while now. But believe it or not I’m still coding some PL/SQL as well now and then. Anyway, sometimes when you get some ClassNotFound exceptions in Java it can be quite handy to have a little tool that can scan .jar and .zip files for the class that you’re missing. Yes, there are tons of those little programs out there on the web but as you might have guessed by the title I’ve decided to write yet another class finding tool. Damn, I really should have called it YACFT! But instead I did go for ClassFinder. Why did I write yet another class finding tool then? Well, although there are some good ones out there, non of them fulfilled all of my requirements – at least none of those that I have found. First I was a big fan of Xigole’s classfinder tool. A really slick, fast and easy to use command-line class finding tool which is really great for Unix systems where you ssh in. However, I soon got fed up with it when I did have a proper graphical interface available, whether it was Windows or X11 or simply my MacBook Pro. So I started searching for other tools and soon found that they were either just GUI based or just GUI based and on Windows only (Why? I don’t get it!) or GUI based on ugly AWT. But all that I wanted was a slick tool like Xigole’s that was clever enough to spawn a GUI when there was X11 available but still provide a nice CLI when there wasn’t. Well, as I said I couldn’t find one, so I wrote my own and here it is, ClassFinder:

ClassFinder Window-mode

It’s really easy to use:

  1. Give it either a file or a folder to search – files currently supported are .jar, .war, .ear, .zip, .rar, .class, .java
  2. Give it the class name that you’re looking for
  3. Shall the class name be case sensitive?
  4. Shall the folder be searched recursively?
  5. Hit Search!

It will go through the folder and sub folder if you’ve checked “Recursive” (default) and look in all the files with the extensions mentioned above whether they contain the class you’re looking for. In case that you will hit a source folder or non-packaged files I’ve included .java and .class files as well.

The outcome looks like this:

ClassFinder Window-mode search

And if you don’t want to search case sensitive, although I think that this is a very rare use case hence “Match case” is checked by default as well, the outcome will still look like this:

ClassFinder Window-mode case insensitive

However, sometimes you’ll have the same class name within different packages and you will get something like this for example:

Class Finder Window-mode without package

Hence why I’ve added support for fully qualified class names which include the package names (really handy when you just copy/paste your ClassNotFound exception message into it):

ClassFinder Window-mode with full qualified package name

If you just type “java -jar ClassFinder.jar” it will try to instantiate the GUI:

ClassFinder command-line window-mode

However, if that is not successful it will print the online help so that you can invoke it via the command line:

ClassFinder command-line search

And in case that you’re really curious where it had a look I’ve added some verbose output as well:

ClassFinder command-line verboseIf you like what you see you can get the tool on Github:

It is my first project on Github and I still try to get my head around git so please go easy on me. Also I think my code quality has gone down due to the lack of coding however, feel free to jump on in on the project if you like!

If you just want to use the tool, you can download a copy here:

But be warned, you will need to run it with Java 7! If you don’t have Java 7 installed yet then I’d say it’s about time but if you have a good enough use case let me know and I’ll port it back to Java 6 or even 5 if required.

Last but not least: Who can guess which show I was watching whilst I was coding ClassFinder, i.e. where did I get the phrase “Good hunting!” from? 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.