Finding unused jars used in an eclipse project
Solution 1:
ClassPathHelper is a good start.
It automatically identifies orphan jars and much more.
The only limitation is with dependencies that are not defined in classes, e.g. in dependency injection framework configuration files.
You also have other options/complements, such as:
- workingfrog "Relief", which relies on the ability to deal with real objects by examining their shape, size or relative place in space it gives a "physical" view on java packages, types and fields and their relationships, making them easier to handle.
- Unnecessary Code Detector: a eclipse PlugIn tool to find unnecessary (dead) public java code.
Solution 2:
UCDetector does not help for this : It does not work on JARs. And for classpathHelper, I wan't able to find out an easy way just to list the orphan JARs (BTW, if someone has a tutorial for this, i am interested).
So, if you are also using Maven as I do, I find out this great Maven plugin, and I would like to share this solution with you. Just type :
mvn dependency:analyze
And you will instantly get a list of unused JARs in your dependencies. Very handy !
Solution 3:
I found a very fast and interesting tool to archive this goal:
http://tattletale.jboss.org/
Just unzip the program and run:
java -Xmx512m -jar tattletale.jar ~/myjavaproject/mydistribution output
This will generate a very impressive report with different points (text from their site):
- Identify dependencies between JAR files
- Find missing classes from the classpath
- Spot if a class/package is located in multiple JAR files
- Spot if the same JAR file is located in multiple locations
- With a list of what each JAR file requires and provides
- Verify the SerialVersionUID of a class
- Find similar JAR files that have different version numbers
- Find JAR files without a version number
- Find unused JAR archives
- Identify sealed / signed JAR archives
- Locate a class in a JAR file
- Get the OSGi status of your project
- Remove black listed API usage
- And generate the same reports for your .WAR and .EAR archives
Solution 4:
You can use one of this plugins: UCDetector or Classpath Helper