Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list dependencies of a JAR

is there a tool that can list third party "packages" that contain (third party) classes referenced in the JAR ? Let say that it would recognize what is "home" package from JAR file definition and it would print out a list of fully qualified names of third party classes up to 3rd level that were referenced within the JAR.

org.apache.commons   org.apache.maven javax.servlet.jsp org.eclipse.persistence org.apache.jackrabbit 

the purpose is that I need to find maven dependencies for that JAR file and deploy it as a maven artifact.

like image 527
lisak Avatar asked Dec 11 '10 17:12

lisak


People also ask

How can I see the dependencies in a JAR file?

jar file. Use the -verbose:class option to find class-level dependencies or use the -v or -verbose option to include dependencies from the same JAR file.

What are jar dependencies?

a dependency management utility for jar files. It's primary purpose is to traverse through a directory, parse each of the jar files in that directory, and identify the dependencies between the jar files. The output is an xml file representing the PhysicalDependencies between the jar files.

Does JAR file contain dependencies?

Normally, when we package a project into a jarW file, the jar file doesn't contain its dependencies, so the dependency jar files would need to be included in the classpathW in order to execute a class in the project's jar file that uses one of the dependencies.

How do I get a list of classes in a JAR file?

You can use Java jar tool. List the content of jar file in a txt file and you can see all the classes in the jar. Also, this won't allow you to inspect annotations, which is likely something you'll want to do if you're scanning classes at runtime.


1 Answers

There is a new tool since JDK 8: jdeps

https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool

jdeps is a new command-line tool added since JDK 8 for developers to use to understand the static dependencies of their applications and libraries. jdeps is a static analysis tool on the given class files

like image 100
Barry Kelly Avatar answered Sep 21 '22 13:09

Barry Kelly