Reputation: 2337
I've two jars, Jar1 used in compilation and Jar2 is not used at compile time.However both Jar1 and Jar2 are present on the classpath.
I tried finding the references of classes for Jar2 but did not find any of the classes used in the application.
But what if the Jar1 uses some classes of Jar2 at runtime ?
How can I be sure enough to delete the Jar2 from the library and the classpath that it is used by Jar1 at run time ?
Is there any tool available which can tell if any jar is not used in any scenarios at run-time with 100% surety ?
[Little background : I am upgrading to newer version of POI, previously distribution had contrib.jar, now this jar is not present in the recent version. I tried compiling the project after removing the contrib.jar and it compiled successfully. But I want to be doubly sure that removing this from the libraires should not have any adverse effect at runtime.]
Regards, JE.
Upvotes: 2
Views: 540
Reputation: 17422
1 - About the "dependency-finder" tool:
In theory, each *.class file has a constant pool where the name of dependencies can be found. However, the code could use reflection and make up the name of classes/interfaces dynamically, so finding out if one jar depends on another to work properly is not an easy task at all.
2 - About your particular case:
It seems like, indeed, you don't need such dependency; but if you really want to double check the only way would be to analyse the code of your project by hand. Even if you found a dependency-finder its result wouldn't be 100% reliable because of what I've explained in my first point.
Upvotes: 2