如何获取主类的Java类依赖关系列表? [英] How do I get a list of Java class dependencies for a main class?

查看:384
本文介绍了如何获取主类的Java类依赖关系列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法找到java主类的所有类依赖?



我已经手动筛选主类的导入,它是导入,然后意识到,因为没有必要导入同一个包中的类,所以我把一个不完整的列表放在一起。



我需要一些可以递归地找到依赖关系的东西(也许定义深度)。

解决方案

可以用javac来完成任务。删除你的类文件,然后编译主类。 javac将递归编译它需要的任何类(提供你不要在奇怪命名的文件中隐藏包私有类/接口)。当然,这不包括任何递归的黑客。


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).

解决方案

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类依赖关系列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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