What is your favorite tool, plugin, script, to find a java class in a bunch of jar files?
Very often I inherit code that complains about a class that doesn't exist, and it is just because the jar file is not included in the classpath. But, in what jar file(s) is the class? I may not have the JAR (so I have to search online), or adding a JAR to the classpath could create a duplicated class definition problem.
I obviously would prefer an eclipse plugin, but I'm open to any piece of software that works with Windows.
I know... Windows is not my choice, but that's what I got to work with.
Thanks!
Luis
P.S. Thank you for your answers. After reviewing some responses, I became aware that I should have explained better my scenario. We had a library of downloaded or created JAR files, but sometimes the class would be online somewhere.
Grepj is a command line utility to search for classes within jar files.
You can run the utility like
grepj package.Class my1.jar my2.war my3.ear
Search scope is
Multiple jar, ear, war files can be provided.
use this:
for x in $(find . -name '*.jar') do unzip -l $x | grep WCCResponseImpl done
(This is an improvement over the script I had in previous versions of the answer as it produces much cleaner output at the price of some
awk
special/ugly quoting.)I've built a script (
findinjars
) which does just that.you can then invoke it with:
or just
Dot characters in the fully qualified class name will be interpreted in the regexp sense of 'any character' but that's not a big deal since this is a heuristics utility (that's why it's case-insensitive too BTW). Usually I don't bother with the full class name and just type part of it.
The best and easiest way is to use the JAD Decompiler. And yes, its an ECLIPSE PLUGIN !
Download and save the plugin in any location on your machine.
The plugin contains the following files:
Perform the following steps:
Now select any class and press F3.
The .class file will automatically decompile and display the contents !
You could always add the Reference library to your project in Eclipse and then in Package Browser, just expand the packages in the JAR file until you find the class that you are looking for.