Over a million developers have joined DZone.

JDeps: Simple Dependency Analysis

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

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

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

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:
dependency analysis

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}