JFind: a simple jar file locator
I'm a big fan of the Unix
find utility for managing large projects. One task that's difficult to do with it, however, is finding which jar file contains a Java class -- you can't use search commands like
grep because it will match on any class that references your target, not just the defining class itself. There are several utilities that do this on the web, but most are big GUI-based tools which seem like overkill for what should be a small job.
java.util.zippackages to do the heavy lifting. Just specify the class or package you want to find and a directory to start your search, and it will report the jar file or path that defines it. For example, to find which jar provides
NetBeans distribution, run:
java -jar jfind.jar org.openide.ErrorManager dist
To find which jar provides the
javax.cryptopackage in the JDK:
java -jar jfind.jar -p javax.crypto JDK-directory
One could write a more complex, Swiss-army-knife-like utility (like the Unix find utility), but sometimes short and sweet works best.