Pre-General Availability: 2017-05-24

jdeps

You use the jdeps command to launch the Java class dependency analyzer.

Synopsis

jdeps [options] classes ...
options

Command-line options.

classes

Name of the classes to analyze. You can specify a class that can be found in the class path, by its file name, a directory, or a JAR file.

Description

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. The options determine the output. By default, jdeps outputs the dependencies to the system output. It can generate the dependencies in DOT language (see the -dotoutput option).

Options for jdeps

-dotoutput dir

Destination directory for DOT file output. If specified, jdeps will generate one dot file per each analyzed archive named archive-file-name.dot listing the dependencies, and also a summary file named summary.dot listing the dependencies among the archives.

-s or -summary

Prints dependency summary only.

-v or -verbose

Prints all class-level dependencies.

-verbose:package

Prints package-level dependencies excluding dependencies within the same archive.

-verbose:class

Prints class-level dependencies excluding dependencies within the same archive.

-cp path or -classpathpath

Specifies where to find class files .

-p pkg name or -packagepkg name

Finds dependencies in the specified package. You can specify this option multiple times for different packages. The -p and -e options are mutually exclusive.

-e regex or -regex regex

Finds dependencies in packages matching the specified regular expression pattern. The -p and -e options are mutually exclusive.

-include regex

Restricts analysis to classes matching pattern. This option filters the list of classes to be analyzed. It can be used together with -p and -e which apply pattern to the dependencies.

-jdkinternals

Finds class-level dependences in JDK internal APIs. By default, it analyzes all classes specified in the -classpath option and input files unless you specified the -include option. You can’t use this option with the -p, -e, and -s options.

Warning: JDK internal APIs may not be accessible in upcoming releases.

-P or -profile

Shows profile or the file containing a package.

-apionly

Restricts analysis to APIs, for example, dependences from the signature of public and protected members of public classes including field type, method parameter types, returned type, and checked exception types.

-R or -recursive

Recursively traverses all dependencies.

-version

Prints version information.

-h, -?, or -help

Prints help message for jdeps.

Example of Analyzing Dependencies

The following example demonstrates analyzing the dependencies of Notepad.jar.

Oracle Solaris, Linux, OS X:

$ jdeps demo/jfc/Notepad/Notepad.jar
Notepad.jar -> java.base
Notepad.jar -> java.desktop
Notepad.jar -> java.logging
   <unnamed> (Notepad.jar)
      -> java.awt
      -> java.awt.event
      -> java.beans
      -> java.io
      -> java.lang
      -> java.net
      -> java.util
      -> java.util.logging
      -> javax.swing
      -> javax.swing.border
      -> javax.swing.event
      -> javax.swing.text
      -> javax.swing.tree
      -> javax.swing.undo

Windows:

C:\Java\jdk1.9.0>jdeps demo\jfc\Notepad\Notepad.jar
Notepad.jar -> java.base
Notepad.jar -> java.desktop
Notepad.jar -> java.logging
   <unnamed> (Notepad.jar)
      -> java.awt
      -> java.awt.event
      -> java.beans
      -> java.io
      -> java.lang
      -> java.net
      -> java.util
      -> java.util.logging
      -> javax.swing
      -> javax.swing.border
      -> javax.swing.event
      -> javax.swing.text
      -> javax.swing.tree
      -> javax.swing.undo

Example Using -P or -profile Option

The following example demonstrates using the -P or -profile option to show the profile that Notepad depends on.

Oracle Solaris, Linux, and OS X:

$ jdeps -profile demo/jfc/Notepad/Notepad.jar
Notepad.jar -> java.base (compact1)
Notepad.jar -> java.desktop (Full JRE)
Notepad.jar -> java.logging (compact1)
   <unnamed> (Notepad.jar)
      -> java.awt                                           Full JRE
      -> java.awt.event                                     Full JRE
      -> java.beans                                         Full JRE
      -> java.io                                            compact1
      -> java.lang                                          compact1
      -> java.net                                           compact1
      -> java.util                                          compact1
      -> java.util.logging                                  compact1
      -> javax.swing                                        Full JRE
      -> javax.swing.border                                 Full JRE
      -> javax.swing.event                                  Full JRE
      -> javax.swing.text                                   Full JRE
      -> javax.swing.tree                                   Full JRE
      -> javax.swing.undo                                   Full JRE

Windows:

C:\Java\jdk1.9.0>jdeps -profile demo\jfc\Notepad\Notepad.jar
Notepad.jar -> java.base (compact1)
Notepad.jar -> java.desktop (Full JRE)
Notepad.jar -> java.logging (compact1)
   <unnamed> (Notepad.jar)
      -> java.awt                                           Full JRE
      -> java.awt.event                                     Full JRE
      -> java.beans                                         Full JRE
      -> java.io                                            compact1
      -> java.lang                                          compact1
      -> java.net                                           compact1
      -> java.util                                          compact1
      -> java.util.logging                                  compact1
      -> javax.swing                                        Full JRE
      -> javax.swing.border                                 Full JRE
      -> javax.swing.event                                  Full JRE
      -> javax.swing.text                                   Full JRE
      -> javax.swing.tree                                   Full JRE
      -> javax.swing.undo                                   Full JRE