How to Determine which JARs are Used in an Application

前端 未结 4 1653
傲寒
傲寒 2021-02-04 06:07

An existing application has a ton of JAR files in its classpath. Someone must have added all JARs initially just to be sure. Some of the JARs were obviously not being used and w

4条回答
  •  无人及你
    2021-02-04 06:42

    Be aware that trial and error alone can be a problem, especially if the application loads classes dynamically (e.g. Class.forName) as removing a JAR might not prevent the application from starting up and (apparently) work fine, but it may fail later if target classes are not found.

    Also, there are many tools that can be used to analyze a Java application and find out dependencies (I have used Dependency Finder myself, although not exactly for this purpose), however note that most of them will also fail to find classes that are loaded dynamically as described above.

提交回复
热议问题