Removing unused classes from jar file
807603Jan 8 2008 — edited Jan 14 2008Folks,
I am trying to create a utility which help to reduce the bundled jar file in any software installation. consider the scenario, in which we use many 3rd party libraries and all these needs to be bundled to make the java application work. But we may use only very few classes from the jar and this results in a large package.
So when user will input a directory path which contains a set of java files and sub classes. I will traverse through them and parse each file to find the classes that are used.
ex.,
import org.apache.abc.Def;
import org.apache.Xyz;
import org.apache.Feg;
from this i will have a list of classes that are used. I can take only those classes from the source jar and put in the destination jar. But my problem comes only when imported classes depends on other classes in the jar. For example Def may depend on org.apache.iop.Xyz which also should be included in the jar. How find the dependency? or is possible to find such dependencies?
Thanks for your help.