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).
The jdeps command shows the package-level or class-level dependencies of Java class files. The input class can be a path name to a . class file, a directory, a JAR file, or it can be a fully qualified class name to analyze all class files.
You can use tools jdeps for check dependencies in classpath (if before JDK 9), but it can not help you check all source code, only apply with standalone Java class. Since JDK 9, you can use modular, with keyword requires inside file module-info. java of module.
Injectable constructors are annotated with @Inject and accept zero or more dependencies as arguments. @Inject can apply to at most one constructor per class. @Inject is optional for public, no-argument constructors when no other constructors are present. This enables injectors to invoke default constructors.
You may want to take a look at the jdeps
command line tool:
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jdeps.html
jdeps -cp <your cp> -v <path to your .class file>
The command will return a list of the dependencies for that java class file. There are many other options that you can use in your command like -regex
to find dependencies matching a given pattern
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With