I have some jars in my project. I want to know how these jars are used or what the effects will be if I remove them?
Remove -> Test -> Remove -> Test -> Remove -> Hope you enjoy :) Change project to maven and select only jar you wanna use. For me this is the easiest way.
A JAR (Java Archive) file is a ZIP format file that bundles Java classes into a single unit. There are two types of JAR file in Java: Library JAR (normal JAR) files: JARs which are reusable libraries.
JAR stands for Java ARchive. It's a file format based on the popular ZIP file format and is used for aggregating many files into one. Although JAR can be used as a general archiving tool, the primary motivation for its development was so that Java applets and their requisite components (.
You can achieve it using loosejar.
It is a simple Java Agent that can be used to discover unnecessary jars lying on application classpath. It performs per classloader JVM heap analysis and displays its results. loosejar can be safely used during development, QA, UAT or even in production as it doesn't modify the state of the JVM at all and adds no overhead.
How to use:
Start your application or application server with -javaagent:loosejar.jar flag (loosejar.jar should obviously point to the correct path of the actual jar)
Exercise your application to make sure that the classes get loaded into the JVM.
Get loosejar analysis results via JMX console (open jconsole and run com.googlecode.loosejar.LooseJarMBean#summary() in MBeans folder) or on application shutdown (via regular console log).
You are using Maven, so you can use Maven's features to have a look what jars you need. Run the following in the root of your project:
mvn dependency:analyze
And you'll see the line [WARNING] Unused declared dependencies found:
with a list of dependencies that you don't actually need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With