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

查看:355
本文介绍了如何在编译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?

推荐答案

您需要类依赖性分析器工具。引用介绍:

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天全站免登陆