Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out which JAR application is not using?

Tags:

In our application through the process of developing a lot of JAR files has been collected. How can I filter out those, which are not used by application anymore? On some easy way?

like image 730
Trick Avatar asked Mar 03 '10 15:03

Trick


1 Answers

If you are sure your you can exercise your application so that it uses all it's jars, you can create a simple perl script:

while (<>) {
    $l{$1}++ if m/\s+from\s+(.+\.jar)/;
}

for $l (keys(%l)) {
    print "$l\n";
}

(lets name it list_jars.pl) and feed it the output of a verbose run:

java -verbose -jar YOUR_APP.jar | perl list_jars.pl

which should list all sources of classes loaded.

like image 145
rsp Avatar answered Sep 28 '22 01:09

rsp