LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

jdeps

analyzes Java class dependencies

TLDR

Analyze package-level dependencies of a JAR
$ jdeps [app.jar]
copy
Print a dependency summary (one line per JAR/module)
$ jdeps -s [app.jar]
copy
Show class-level dependencies
$ jdeps -verbose:class [app.jar]
copy
Check for JDK internal API usage
$ jdeps --jdk-internals [app.jar]
copy
Print the JDK modules needed, ready for jlink --add-modules
$ jdeps --print-module-deps --ignore-missing-deps --class-path '[lib/*]' [app.jar]
copy
Generate module-info.java for a JAR
$ jdeps --generate-module-info [output_dir] [app.jar]
copy
Find dependencies on a specific package
$ jdeps -p [com.example] [app.jar]
copy
Analyze a multi-release JAR for a given Java version
$ jdeps --multi-release [17] [app.jar]
copy
Write DOT graph files for visualization
$ jdeps --dot-output [output_dir] [app.jar]
copy

SYNOPSIS

jdeps [options] path...

DESCRIPTION

jdeps is the Java class dependency analyzer. It shows the package-level or class-level dependencies of Java class files, and which JARs and JDK modules they rely on.The tool helps with migrating to the Java module system and with building minimal runtimes: --print-module-deps feeds directly into jlink, and --jdk-internals flags use of internal JDK APIs that are inaccessible under strong encapsulation (JDK 16+) or may be removed.

PARAMETERS

PATH

A .class file, a directory of classes, or a JAR file.
-s, -summary
Print dependency summary only.
-v, -verbose
Print all class-level dependencies (same as -verbose:class -filter:none).
-verbose:package, -verbose:class
Print package-level (default) or class-level dependencies.
-cp, --class-path path
Where to find dependent class files.
--module-path path
Module path.
--multi-release VERSION
Version to use when processing multi-release JARs (integer >= 9, or base).
--jdk-internals
Find class-level dependencies on JDK internal APIs. Cannot be combined with -p, -e or -s.
-p, --package PACKAGE
Find dependencies matching the given package (repeatable).
-e, --regex REGEX
Find dependencies matching the given pattern.
--require MODULE
Find dependencies on the given module.
-include REGEX
Restrict analysis to classes matching the pattern.
-R, --recursive
Recursively traverse all run-time dependencies.
--api-only
Only consider dependencies from public API signatures.
--list-deps, --list-reduced-deps
List module dependencies (the reduced form omits implied reads edges).
--print-module-deps
Print a comma-separated list of module dependencies, suitable for jlink --add-modules.
--ignore-missing-deps
Ignore missing dependencies instead of failing.
--missing-deps
Find missing dependencies.
--generate-module-info DIR
Generate module-info.java for the given JARs under DIR.
--generate-open-module DIR
Like --generate-module-info, but generate open modules.
--check MODULE[,...]
Analyze the given modules, print their descriptors and unused qualified exports.
--dot-output DIR
Write DOT files for graph visualization.
-q, -quiet
Suppress warning messages.
--help
Display help information.

CAVEATS

Part of the JDK. Analyzes compiled class files, not source. Dependencies reached through reflection, ServiceLoader or string class names are not detected. Libraries missing from --class-path cause errors for module-level options unless --ignore-missing-deps is used.

HISTORY

jdeps was added in JDK 8 to help developers understand dependencies and prepare for the Java module system introduced in JDK 9, which added the module-related options.

SEE ALSO

javap(1), java(1), jar(1), javac(1)

RESOURCES

Copied to clipboard
Kai