Finding a Class in a ton of jars
This is how I do it. Create a script I call it findclass in some location on the path. /usr/local/bin is a good place, I prefer $HOME/bin. Remember to chmod this script to 755.
#!/bin/bash
find -iname "*.jar" | xargs -i unzip -l {} | less
In case you are new to less, here’s how you navigate:
1. To find a particular class say com.xyz.abc.MyClass, you type:
/com.xyz.abc.MyClass
2. To find what jar contains this class, you type:
?Archive:
How’s this:
find . -name “*.jar” | xargs -i unzip -l {} | grep -E “^Archive:|$1″ | less
Example:
> findclass Enclosed
Archive: ./aspectj-1.5.3.jar
Archive: ./aspectjweaver.jar
Archive: ./junit.jar
651 27-03-07 14:22 org/junit/runners/Enclosed.class
Fewer things to navigate, easier to find the archives containing the matching classes.
Josh G
26 Jul 07 at 1:08 pm
That’s an interesting way as well, actually
Ketan
26 Jul 07 at 1:29 pm