How do I get a list of Java class dependencies for a main class?(如何获取主类的 Java 类依赖项列表?)
问题描述
有没有办法找到一个java主类的所有类依赖?
Is there a way to find all the class dependencies of a java main class?
我一直在手动筛选主类的导入及其导入,但后来意识到,因为不必导入同一个包中的类,所以我整理了一个不完整的列表.
I have been manually sifting through the imports of the main class and it's imports but then realized that, because one does not have to import classes that are in the same package, I was putting together an incomplete list.
我需要一些能够递归地找到依赖关系的东西(可能达到定义的深度).
I need something that will find dependencies recursively (perhaps to a defined depth).
推荐答案
只用 javac 就可以轻松搞定.删除你的类文件,然后编译主类.javac 将递归编译它需要的任何类(前提是您不将包私有类/接口隐藏在奇怪命名的文件中).当然,这不包括任何递归 hack.
It can be eaily done with just javac. Delete your class files and then compile the main class. javac will recursively compile any classes it needs (providing you don't hide package private classes/interfaces in strangely named files). Of course, this doesn't cover any recursive hacks.
这篇关于如何获取主类的 Java 类依赖项列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何获取主类的 Java 类依赖项列表?


基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01