Reputation: 1112
How do I find unneed JARS in my Java Projects. I am taking over a number of java projects that has alot of JARs in them and I have a feeling I dont need them.. Can someone please tell me if you know any quick tricks on finding out which JARs a project needs or dont need.
Below is the JAR list of a Spring Web Flow project with MySQL and Hibernate I dont then I need all the JARs but can someone tell me some tricks
activation-1.1.jar
antlr-2.7.6.jar
aopalliance-1.0.jar
asm-3.1.jar
asm-attrs-1.5.3.jar
aspectjrt-1.6.8.jar
aspectjweaver-1.6.8.jar
c3p0-0.9.2-pre4.jar
cas-client-core-3.2.1.jar
cglib-2.2.jar
commons-beanutils-1.8.0.jar
commons-codec-1.4.jar
commons-collections-3.1.jar
commons-dbcp.jar
commons-digester-1.8.1.jar
commons-email-1.0.jar
commons-fileupload-1.1.1.jar
commons-io-1.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-pool.jar
dom4j-1.6.1.jar
dumbster-1.6.jar
ehcache-1.2.3.jar
files.txt
hibernate-annotations-3.5.0-Final.jar
hibernate-commons-annotations-3.2.0.Final.jar
hibernate-core-3.5.0-Final.jar
hibernate-entitymanager-3.5.0-Final.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate-search-3.0.0.GA.jar
hibernate-validator-4.0.2.GA.jar
hsqldb-1.8.0.10.jar
httpclient-4.1.2.jar
httpclient-cache-4.1.2.jar
httpcore-4.1.2.jar
httpmime-4.1.2.jar
icu4j-2.6.1.jar
jackson-core-asl-1.5.3.jar
jackson-mapper-asl-1.5.3.jar
javassist-3.9.0.GA.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.3.jar
jaxen-1.1.1.jar
jcl-over-slf4j-1.5.10.jar
jdom-1.0.jar
joda-time-1.6.jar
joda-time-jsptags-1.0.2.jar
jstl-1.2.jar
jta-1.1.jar
log4j-1.2.14.jar
log4j-1.2.15.jar
lucene-core-2.3.2.jar
lucene-highlighter-2.0.0.jar
mail-1.4.jar
mailapi.jar
mail.jar
mchange-commons-java-0.2.2.jar
mysql-connector-java-5.0.5.jar
org.springframework.aop-3.1.1.RELEASE.jar
org.springframework.asm-3.1.1.RELEASE.jar
org.springframework.aspects-3.1.1.RELEASE.jar
org.springframework.beans-3.1.1.RELEASE.jar
org.springframework.binding-2.3.1.RELEASE.jar
org.springframework.context-3.1.1.RELEASE.jar
org.springframework.context.support-3.1.1.RELEASE.jar
org.springframework.core-3.1.1.RELEASE.jar
org.springframework.expression-3.1.1.RELEASE.jar
org.springframework.faces-2.3.1.RELEASE.jar
org.springframework.instrument-3.1.1.RELEASE.jar
org.springframework.instrument.tomcat-3.1.1.RELEASE.jar
org.springframework.jdbc-3.1.1.RELEASE.jar
org.springframework.jms-3.1.1.RELEASE.jar
org.springframework.js-2.3.1.RELEASE.jar
org.springframework.js.resources-2.3.1.RELEASE.jar
org.springframework.orm-3.1.1.RELEASE.jar
org.springframework.oxm-3.1.1.RELEASE.jar
org.springframework.test-3.1.1.RELEASE.jar
org.springframework.transaction-3.1.1.RELEASE.jar
org.springframework.web-3.1.1.RELEASE.jar
org.springframework.webflow-2.3.1.RELEASE.jar
org.springframework.web.portlet-3.1.1.RELEASE.jar
org.springframework.web.servlet-3.1.1.RELEASE.jar
org.springframework.web.struts-3.1.1.RELEASE.jar
persistence-api-1.0.jar
quartz-1.5.2.jar
slf4j-api-1.5.10.jar
slf4j-log4j12-1.5.10.jar
smtp.jar
spring-ldap-1.3.1.RELEASE-all.jar
spring-security-cas-3.1.0.RELEASE.jar
spring-security-config-3.1.0.RELEASE.jar
spring-security-core-3.1.0.RELEASE.jar
spring-security-crypto-3.1.0.RELEASE.jar
spring-security-ldap-3.1.0.RELEASE.jar
spring-security-openid-3.1.0.RELEASE.jar
spring-security-remoting-3.1.0.RELEASE.jar
spring-security-taglibs-3.1.0.RELEASE.jar
spring-security-web-3.1.0.RELEASE.jar
spring-tx-3.0.5.RELEASE.jar
stax-api-1.0-2.jar
tiles-api-2.1.3.jar
tiles-core-2.1.3.jar
tiles-jsp-2.1.3.jar
tiles-servlet-2.1.3.jar
urlrewritefilter-3.1.0.jar
validation-api-1.0.0.GA.jar
xalan-2.6.0.jar
xml-apis-1.3.02.jar
xmlParserAPIs-2.6.2.jar
xom-1.0.jar
Upvotes: 5
Views: 1094
Reputation: 7218
You could try running JBoss Tattletale over your application. This will give you a report on the dependencies of your application including but not limited to un-used jars, duplicate jars with different version numbers etc.
Upvotes: 1
Reputation: 447
If you're using Eclipse IDE, I recommend you to download and use ClassPath Helper
The document for unused jars can be found here: Unreferenced Classes
However, please read the notice:
In cases where Class.forName() is used to load a classes, which is common in many frameworks including struts, WAR web.xml files, EJB descriptors, etc. Interface constants (static final constants) are compiled inline. This means that although there's a compile time dependency on the constants at runtime there is no reference to the declaring interface/class
Update:
I'm using Eclipse Helios Service Release 2 and it works fine for me. There is one thing you need to make sure, you must explore your project by using Package Explorer (not Project Explorer as usual) then go to Window -> Show View -> Other -> ClassPath Helper choose ClassPath View.
Upvotes: 0
Reputation: 15008
The best way would to use a project manager like Maven that would automatically handle dependencies for you. This would probably be the best long term solution
The brute force way would be to move all your jars into another folder and just keep trying to compile your project. You'll get lots of missing class errors, so you figure out which jar has the class (Google might help here), add it, then compile again.
Those are the only two ways I can think of
Upvotes: 5