tags:

views:

257

answers:

3

I'm working in a Java project where the axis 2 library from Apache is being used. The axis 2 library is composed of about 20 jar files and some of these are not used project. What I want to know if there is a method to identify which of those jar files are the unused ones.

I'm using the Eclipse IDE an I thought that one way to solve the problem is to add one jar at time until the I get no error messages about the missing classes. However, I'm not sure if this will work as some of the missing classes errors show up only at runtime.

Does anyone know a better way to solve this problem?

+3  A: 

tattletale FTW

http://www.jboss.org/tattletale

JBoss Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on.

The tool will provide you with reports that can help you Identify dependencies between JAR files Spot if a class 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

alamar
I will try tattletale. Does anyone knows if tattletales is able to indentify runtime class dependencies?
Alceu Costa
What's "runtime class dependencies"? I guess no if you mean reflection, Class.forName and stuff.
alamar
Runtime dependencies refers not just to reflective code, but also to transitive dependencies, i.e. A depends on B depends on C. You application might compile fine, but fail when deployed because C isn't there.
skaffman
Well, it does that.
alamar
It looks like that this problem is harder to solve than I first expected.
Alceu Costa
The problem is that I think that axis 2 uses reflection... so the tattletale solution may not work in this case.
Alceu Costa
I doubt it uses the kind of reflection that would prevent tattletale from working.
alamar
A: 

I would follow your original idea of adding one jar at time until it compiles.

You're right that you can still find run-time errors, but unless the application is too big for a good coverage with manual tests, I would simply run and test it to add any missing jars.

Bruno Rothgiesser
A: 

I don't think you can reliably remove jars since classes may be resolved at runtime e.g. using

Class.forName(className);

You may be able to determine the class names used for the above, but it's unlikely.

Since classes will be requested/resolved at runtime, you could run your (comprehensive) test suite to determine whether stuff still works. But ultimately I would be very wary of removing jars from a package like Axis. I assume they're there for a purpose. Is the jar file size really a problem ?

Brian Agnew