jdeps
You use the jdeps command to launch the Java class dependency analyzer.
Synopsis
jdeps [options] path ...
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, the jdeps command writes the dependencies to the system output. The command can generate the dependencies in DOT language (see the -dotoutput option).
Possible Options
-
-dotoutput diror--dot-output dir -
Specifies the destination directory for DOT file output. If this option is specified, then the
jdepscommand generates one.dotfile for each analyzed archive namedarchive-file-name.dotthat lists the dependencies, and also a summary file namedsummary.dotthat lists the dependencies among the archive files. -
-sor-summary -
Prints a dependency summary only.
-
-vor-verbose -
Prints all class-level dependencies. This is equivalent to
-verbose:class -filter:none -
-verbose:package -
Prints package-level dependencies excluding, by default, dependencies within the same package.
-
-verbose:class -
Prints class-level dependencies excluding, by default, dependencies within the same archive.
-
-apionlyor--api-only -
Restricts the analysis to APIs, for example, dependencies from the signature of
publicandprotectedmembers of public classes including field type, method parameter types, returned type, and checked exception types. -
-jdkinternalsor--jdk-internals -
Finds class-level dependencies in the JDK internal APIs. By default, this option analyzes all classes specified in the
--classpathoption and input files unless you specified the-includeoption. You can’t use this option with the-p,-e, and-soptions.Warning: The JDK internal APIs are inaccessible.
-
-cp path,-classpath path, or--class-path path -
Specifies where to find class files.
-
--module-path module-path -
Specifies the module path.
-
--upgrade-module-path module-path -
Specifies the upgrade module path.
-
--system java-home -
Specifies an alternate system module path.
-
--add-modules module-name [, module-name...] -
Adds modules to the root set for analysis.
-
--multi-release version -
Specifies the version when processing multi-release JAR files.
versionshould be an integer >=9 or base. -
—qor-quite -
Doesn’t show missing dependencies from
–generate-module-infooutput. -
-versionor--version -
Prints version information.
Module Dependency Analysis Options
-
–m module-nameor--module module-name -
Specifies the root module for analysis.
-
--generate-module-info dir -
Generates
module-info.javaunder the specified directory. The specified JAR files will be analyzed. This option cannot be used with--dot-outputor--class-pathoptions. Use the--generate-open-moduleoption for open modules. -
--generate-open-module dir -
Generates
module-info.javafor the specified JAR files under the specified directory as open modules. This option cannot be used with the--dot-outputor--class-pathoptions. -
--check module-name [, module-name...] -
Analyzes the dependencies of the specified modules. It prints the module descriptor, the resulting module dependencies after analysis, and the graph after transition reduction. It also identifies any unused qualified exports.
-
--list-deps -
Lists the module dependencies. It also prints any internal API packages if referenced. This option transitively analyzes libraries on class path and module path if referenced. Use the
--no-recursiveoption for non-transitive dependency analysis. -
--list—reduced-deps -
Same as
--list-depswith not listing the implied reads edges from the module graph. If module M1 reads M2, and M2 requires transitive on M3, then M1 reading M3 is implied and is not shown in the graph. -
--print-module-deps -
Same as
--list-reduced-depswith printing a comma-separated list of module dependencies. This output can be used byjlink --add-modulesin order to create a custom image containing those modules and their transitive dependencies. -
--ignore-missing-deps - Ignore missing dependencies.
Options to Filter Dependencies
-
-p pkg name,-package pkg name, or--package pkg name -
Finds dependencies matching the specified package name. You can specify this option multiple times for different packages. The
-pand-eoptions are mutually exclusive. -
-e regex,-regex regex, or--regex regex -
Finds dependencies matching the specified pattern. The
-pand-eoptions are mutually exclusive. -
--require module-name -
Finds dependencies matching the given module name (may be given multiple times). The
--package,--regex, and--requireoptions are mutually exclusive. -
-f regexor-filter regex -
Filters dependencies matching the given pattern. If given multiple times, the last one will be selected.
-
-filter:package -
Filters dependencies within the same package. This is the default.
-
-filter:archive -
Filters dependencies within the same archive.
-
-filter:module -
Filters dependencies within the same module.
-
-filter:none -
No
-filter:packageand-filter:archivefiltering. Filtering specified via the-filteroption still applies. -
--missing-deps - Finds missing dependencies. This option cannot be used with -p, -e and -s options.
-
--recursive - Recursively traverse all run-time dependencies. The
-Roption implies -filter:none. If-p,-e,-foption is specified, only the matching dependencies are analyzed. -
--no-recursive - Do not recursively traverse dependencies.
Options to Filter Classes to be Analyzed
-
-include regex -
Restricts analysis to the classes matching pattern. This option filters the list of classes to be analyzed. It can be used together with
-pand-e, which apply the pattern to the dependencies. -
-Por-profile -
Shows the profile containing a package.
-
-Ror-recursive -
Recursively traverses all run-time dependencies. The
-Roption implies-filter:none. If-p,-e, or-foptions are specified, only the matching dependencies are analyzed. -
-Ior-inverse -
Analyzes the dependencies per other given options and then finds all artifacts that directly and indirectly depend on the matching nodes. This is equivalent to the inverse of the compile-time view analysis and the print dependency summary. This option must be used with the
--require,--package, or--regexoptions. -
--compile-time -
Analyzes the compile-time view of transitive dependencies, such as the compile-time view of the
-Roption. Analyzes the dependencies per other specified options. If a dependency is found from a directory, a JAR file, or a module, all classes in that containing archive are analyzed.
Example of Analyzing Dependencies
The following example demonstrates analyzing the dependencies of the Notepad.jar file.
Oracle Solaris, Linux, and macOS:
$ 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 the --inverse Option
$ jdeps --inverse --require java.xml.bind
Inverse transitive dependences on [java.xml.bind]
java.xml.bind <- java.se.ee
java.xml.bind <- jdk.xml.ws
java.xml.bind <- java.xml.ws <- java.se.ee
java.xml.bind <- java.xml.ws <- jdk.xml.ws
java.xml.bind <- jdk.xml.bind <- jdk.xml.ws