Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

JDeps: Simple Dependency Analysis

DZone's Guide to

JDeps: Simple Dependency Analysis

Learn about a nifty new utility that creates simple dependency graphs of Java CLASS files.

· Java Zone ·
Free Resource

Secure your Java app or API service quickly and easily with Okta's user authentication and authorization libraries. Developer accounts are free forever. Try Okta Instead.

In Java 8 we have a new command line tool called jdeps to know the Java dependencies. It is a nice tool to do static analysis and find out the .class/jar dependencies.

For example, I have a class and wanted to know the dependencies summary as DOT (graph description language) format I can get it by issuing the below jdeps command.

D:\>jdeps -dotoutput .  -cp jsoup-1.7.2.jar D:\classes\org\smarttechies\harvester\ProductInfoHarvester.class

Here -dotoutput <dir> option generates the DOT file for given class/jar archive and a summary DOT file under the given directory.

From the above example, jdeps generates package level dependency. The DOT visualization is given below.

jdeps package level dependency

If we want the verbose class level dependency, we can generate by passing -v option to the jdpes.

D:\>jdeps -dotoutput . -v -cp jsoup-1.7.2.jar D:\bin\org\smarttechies\harvester\ProductInfoHarvester.class

From the above example, jdeps generates classlevel dependency. The DOT visualization is given below.

jdeps class level dependency

If you want to know more options get it from help jdeps -help

Secure your Java app or API service quickly and easily with Okta's user authentication and authorization libraries. Developer accounts are free forever. Try Okta Instead.

Topics:
dependency analysis

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}