jdeps
Analyze Java class dependencies
TLDR
Analyze the dependencies of a .jar or .class file
Print a summary of all dependencies of a specific .jar file
Print all class-level dependencies of a .jar file
Output the results of the analysis in a DOT file into a specific directory
Display help
SYNOPSIS
jdeps [options] mainclass|jarfile|classfile|directory|jmodfile[@fileslist]
PARAMETERS
-verbose[:class|package|position|dependency|verbose:class[=filter]]
Enable verbose output; specify class, package, position, or dependency details
--filter
Filter classes matching regex pattern
-ap
Map class name prefix to archive prefix
-dotoutput
Generate class dependency graph in DOT format to directory
-summary
Show summary of dependencies
-tree
Show dependency tree
--multi-release
Select multi-release JAR version
--module-path
Set module path
--add-modules
Root modules to resolve
-include-local
Include local class/package dependencies
-exclude-local
Exclude local class/package dependencies
--check
Check dependencies matching regex
-Werror
Fail on warnings
-quiet
Suppress non-error messages
--help | -h
Show help
--version | -V
Show version
DESCRIPTION
The jdeps command analyzes dependencies in Java class files, JAR files, or modules, helping developers understand package-level and class-level dependencies. It identifies reliance on internal JDK APIs, deprecated features, and external modules, aiding in migration to modular Java applications.
Key features include generating dependency graphs in DOT format for visualization, filtering dependencies, and checking against specific patterns. It supports multi-release JARs and provides verbose output for detailed analysis.
Primarily used for refactoring legacy code, ensuring compatibility, and optimizing module paths in JDK 9+. It scans bytecode without executing code, making it safe for large applications. Output formats include summaries, trees, and graphs, facilitating static analysis in build pipelines or IDEs.
CAVEATS
Requires JDK 8+; analyzes bytecode only, not source code. Internal API usage warnings may not cover all cases. Large JARs can be slow without filtering.
COMMON USAGE
jdeps -dotoutput outdir myapp.jar
Generates DOT files for Graphviz visualization.
jdeps --module-path mods -summary app.jar
Summarizes modular dependencies.
OUTPUT INTERPRETATION
Uses arrows for 'depends on'; JDK internal APIs marked with warning triangle (▲). Package summaries show forward/backward dependencies.
HISTORY
Introduced in JDK 8 (2014) as part of Java mission control tools. Enhanced in JDK 9+ for module support and multi-release JARs. Maintained in OpenJDK for dependency analysis in modular era.


