Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a tool to discover if the same class exists in multiple jars in the classpath?

Tags:

If you have two jars in your classpath that contain different versions of the same class, the classpath order becomes critical.

I am looking for a tool that can detect and flag such potential conflicts in a given classpath or set of folders.

Certainly a script that starts:

classes=`mktemp`
for i in `find . -name "*.jar"`
do
    echo "File: $i" > $classes
    jar tf $i > $classes
    ...
done

with some clever sort/uniq/diff/grep/awk later on has potential, but I was wondering if anyone knows of any existing solutions.

like image 716
David Citron Avatar asked Sep 25 '08 20:09

David Citron


People also ask

How do I find a class file in a bunch of JARs?

Eclipse can do it, just create a (temporary) project and put your libraries on the projects classpath. Then you can easily find the classes. Another tool, that comes to my mind, is Java Decompiler. It can open a lot of jars at once and helps to find classes as well.

How do you check if a class exists in a jar file?

To find the . jar files that contain a class, you can use the FindClass.sh script. First go to a UNIX installation of Sterling Platform/MCF. If the FindClass.sh script already exists it should be in your $YFS_HOME directory or your $YFS_HOME/lib directory.


1 Answers

Looks like jarfish will do what you want with its "dupes" command.

like image 66
Zac Thompson Avatar answered Sep 22 '22 23:09

Zac Thompson