Tuesday, October 6, 2009

find class or classes in jar for Unix or Windows

http://www.inetfeedback.com/jarscan/ on Unix

Examples ...
# To display the help message type:
java -jar jarscan.jar -help OR java -jar jarscan.jar
# To find the class ArrayList starting from the root of your c: drive type:
java -jar jarscan.jar -dir c:\ -class ArrayList

http://www.idesksoft.com/classfinder.html on Windows

Also, this command works on Linux:

find / -name '*.jar' 2> /dev/null | while read jarfile; do if jar tf "$jarfile" 2> /dev/null | grep FabricMeshUtils; then echo "$jarfile"; fi; done

(maybe you want to add a "| grep jar", otherwise it returns also .class files.

To dump all classes preceded by their jar file name:
find /acme/appsrv/bin/wl12.1a/ -type f -name '*.jar' | while read jarfile; do echo "$jarfile"; /acme/java/jdk170_71-64b/bin/jar -tf "$jarfile" ; done > /tmp/alljars.txt

Last but not least the great jar-explorer https://code.google.com/p/jar-explorer/wiki/HowToInstall, or rather https://github.com/javalite/jar-explorer. just run:

java -jar jarexplorer-0.7-BETA.jar

and remember that to search a class with package names you have to use the / and not the . as separator.

This command works also wonderfully:

find /cs/cfw/ -name "*.jar" -exec grep -Hls MyClass {} \;

No comments: