Trimming my Java project

I am currently working on a project that uses the jfreechart library. I am currently using a jar file for this library, adding it to my build path. However, I do not need all the functionality of the library. I would like to highlight only those sections of the library in which I used my code and, obviously, dependent code.

My ultimate goal is to reduce the size of the project. I need to fulfill some target values, and using an entire banner library of 7 mb is not an option.

I wanted to know if there is a way to do this separately from manually checking dependencies?

Ideally, I would like to apply any proposed method to the jar file of the library, but if there is a convenient way to detect unused code in the source code, I am ready to import the source code into my project.

I apologize if my request is a repetition or a stupid question.

Thanks Sudipto

+7
source share
2 answers

Unfortunately, you cannot do this without (possibly) violating the JFreeChart license.

JFreeChart is licensed under the Lesser GNU Public License, and one of the principles of this license is that the end user must have the right to modify or replace the licensed software embedded in your software. If you select classes from JFreeChart and include them in your JAR, you make it difficult for users to use their rights to replace the built-in JFreeChart classes. This certainly goes against the spirit of the LGPL.

See the GNU LGPL and Java pages for more information.


If you want to do this using JFreeChart, you will need to obtain permission from the copyright holder. If your manager is really interested in reducing the size of the download, a large donation to the JFreeChart project could help them get their mindset. (Disclaimer - I have nothing to do with the project.)

+5
source

This is really difficult to determine, because the execution paths of the application may be different for each launch. However, there is an Instrumentation interface that can show you all the classes that the JVM is currently loading. This should give you an idea of ​​which classes to keep. While you use all possible results of the application.

Generally speaking, this is certainly a bad idea, but since you asked ...

+4
source

All Articles