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.io and java.util.zip packages 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 org.openide.ErrorManager in aNetBeans distribution, run:
java -jar jfind.jar org.openide.ErrorManager <i>dist</i>To find which jar provides the
javax.crypto package in the JDK: java -jar jfind.jar -p javax.crypto <i>JDK-directory</i>One could write a more complex, Swiss-army-knife-like utility (like the Unix find utility), but sometimes short and sweet works best.
- Login or register to post comments
- Printer-friendly version
- tball's blog
- 3946 reads





