DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

SBOMs are essential to circumventing software supply chain attacks, and they provide visibility into various software components.

Related

  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • Using Event-Driven Ansible to Monitor Your Web Application
  • The Blue Elephant in the Room: Why PHP Should Not Be Ignored Now or Ever
  • Azure Deployment Using FileZilla

Trending

  • The Agile Paradox
  • Stop Prompt Hacking: How I Connected My AI Agent to Any API With MCP
  • Why Tailwind CSS Can Be Used Instead of Bootstrap CSS
  • Deploy Serverless Lambdas Confidently Using Canary

Remove Unnecessary Jars!

By 
Altuğ Altıntaş user avatar
Altuğ Altıntaş
·
Jun. 26, 13 · Interview
Likes (0)
Comment
Save
Tweet
Share
21.8K Views

Join the DZone community and get the full member experience.

Join For Free
Your application may turn into Jar garbage maybe not in small projects but in projects which has an increasing diameter more and more. I’m sure once upon a time you thought to have an application and then remove the unnecessary Jars with it. We use Jar libraries in our projects sometimes for a need and sometimes for developing software easily. One of the biggest reasons of why projects turn into Jar garbage may result from not knowing which library serves for what. Thus, due to the dependencies we include Jar libraries in projects, explicitly whatever we find, because of not getting compile and runtime exceptions. For this purpose, I want to introduce you an excellent software tool to detect unused Jars.

LooseJar LooseJar is software that discovers which Jar file is used how often through Java Instrumentation library. Instrumentation is a standard library which serves measurement process about code without affecting the ordinary operation of Java codes and allows obtaining a variety of information.

How to Run LooseJar? You have to define software as Java agent in your application’s JVM parameter. For example:

java -javaagent:<LooseJar Path> <Your ClassName> -cp <Your Jars>
You can use Java agent as in the above syntax example. If your application is a web application, you can define Java agent at JVM settings of the default application server. Point to be considered here is testing points dependent to all libraries from running to termination of the application in order to obtain detection about which library is used how often. Unit tests and BDD tests can be used to measure the overall Looser application and Selenium tests can be used if web application is being used. For example you have a method named getSQLConnection(). This method requires sql connection and uses mysql connector driver in the background. If this method is not called when Looser agent is active, Looser agent provide you information about mysql dependency is not being used. This point must be considered in the use of Looser.


Conclusion So, how Looser will give us information about which Jar is used how much? There are two ways to obtain this information. Firstly, this information is provided as a console output immediately after the application is terminated. The second way is accessing with JMX connection in the run-time and accessing to summary() method of Looser as MBean method. JMX Jconsole or VisualVM can be used to access with JMX.

A sample output:

If your applications' result contains any 0.00% rated Jars, you can remove it from CLASSPATH. 

Real content above, can be accessed at http://en.kodcu.com/2013/06/remove-unnecessary-jars/

JAR (file format) Web application

Opinions expressed by DZone contributors are their own.

Related

  • Cookies Revisited: A Networking Solution for Third-Party Cookies
  • Using Event-Driven Ansible to Monitor Your Web Application
  • The Blue Elephant in the Room: Why PHP Should Not Be Ignored Now or Ever
  • Azure Deployment Using FileZilla

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: