编译java项目时如何找出实际使用的jar文件 [英] How do I find out what jar files are actually used when compiling a java project

查看:26
本文介绍了编译java项目时如何找出实际使用的jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将一个非常大的类路径传递给 javac 以编译一个 java 项目.

I'm currently passing a very large classpath to javac to compile a java project.

我知道其中一些 jar 文件是不需要的.

I know that a number of those jar files aren't needed.

有没有一种简单的方法可以找出哪些文件不需要?

Is there a simple way of finding out which files aren't needed?

推荐答案

您需要 Class Dependency Analyzer 工具.引用介绍:

You need the Class Dependency Analyzer tool. To quote the introduction:

此工具的目的是分析 Java™ 类文件,以了解有关这些类之间依赖关系的更多信息.

The purpose of this tool is to analyze Java™ class files in order to learn more about the dependencies between those classes.

确实,它不会捕获运行时依赖项 - 但如果没有运行详尽的 100% 覆盖率测试套件,您永远无法确定您已捕获所有运行时依赖项.

True, it won't catch runtime dependencies - but short of running an exhaustive 100% coverage test suite you can never be sure you've caught all runtime dependencies.

如果您期望运行时依赖项,则应首先使用 CDA,然后对生成的应用程序进行详尽测试,以确保没有仅通过运行时依赖项引用的 jar 文件.

If you expect runtime dependencies you should use the CDA as a first-pass, then do exhaustive testing of the resultant app to ensure that there are no jar files which were only referenced through runtime dependencies.

这篇关于编译java项目时如何找出实际使用的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆