How can I identify unnecessary jars included in my project?

前端 未结 3 1132
甜味超标
甜味超标 2021-01-13 12:53

I\'m working in a Java project where the axis 2 library from Apache is being used. The axis 2 library is composed of about 20 jar files and some of these are not used projec

相关标签:
3条回答
  • 2021-01-13 13:34

    I don't think you can reliably remove jars since classes may be resolved at runtime e.g. using

    Class.forName(className);
    

    You may be able to determine the class names used for the above, but it's unlikely.

    Since classes will be requested/resolved at runtime, you could run your (comprehensive) test suite to determine whether stuff still works. But ultimately I would be very wary of removing jars from a package like Axis. I assume they're there for a purpose. Is the jar file size really a problem ?

    0 讨论(0)
  • 2021-01-13 13:39

    tattletale FTW

    http://www.jboss.org/tattletale

    JBoss Tattletale is a tool that can help you get an overview of the project you are working on or a product that you depend on.

    The tool will provide you with reports that can help you

    • Identify dependencies between JAR files
    • Spot if a class is located in multiple JAR files
    • Spot if the same JAR file is located in multiple locations
    • With a list of what each JAR file requires and provides
    0 讨论(0)
  • 2021-01-13 13:50

    I would follow your original idea of adding one jar at time until it compiles.

    You're right that you can still find run-time errors, but unless the application is too big for a good coverage with manual tests, I would simply run and test it to add any missing jars.

    0 讨论(0)
提交回复
热议问题