Jar

To inspect a jar archive use the following command, where file.jar is the jar you want to inspect:

jar tf file.jar

Listed below is a combination of commands that checks all jar files in the current directory (and all subdirectories) for duplicate classes. This can be useful if you're getting class linker errors, since they can be caused by having duplicate classes in difference jars, loaded at different times by whatever container you're using.

find ./shared -name "*.jar" -exec jar tf {} \; | grep ".class" | sort | uniq -cd

The combination of the find and jar commands outputs a list of all files in all jars. grep removes all files other than those with ".class" in the name. The list is then sorted by the sort command and parsed for identical lines by the uniq command. It outputs all matches to stdout, each one prefixed with an indication of how many matches were found.

Unfortunately it only tells you how many duplicates there are and what the file is - it doesn't tell you which jars they're in. Maybe I'll extend it later .

Last modified: 07/05/2006 (most likely earlier as a site migration in 2006 reset some dates) Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top