jdeps(1)
π jdeps β the manual page, but make it make sense
okay so bestie, welcome to jdeps(1) from the Basic Tools crew β¨ this is the Java class dependency analyzer and honestly? it's giving detective energy π it sniffs out who's depending on who in your Java class files, and it does NOT gatekeep.
πΈ NAME πΈ
jdeps β Java class dependency analyzer. that's it, that's the whole vibe. she analyzes dependencies π
β¨ SYNOPSIS β¨
jdeps [options] classes ...
optionsβ command-line options. peep the Options section below πclassesβ the names of the classes you wanna analyze. you can name a class that's findable in the class path, or point at it by its file name, a directory, or a JAR file. so many options, we love a flexible queen π«Ά
π¦ DESCRIPTION π¦
jdeps shows you the package-level or class-level dependencies of Java class files. she's nosey in the best way.
your input class can be literally any of these:
- a path name to a
.classfile - a directory
- a JAR file
- a fully qualified class name (in which case she analyzes all class files, overachiever π)
the options decide what the output looks like. by default, jdeps prints the dependencies straight to the system output β no cap. and if you want the fancy graph version, she can generate dependencies in DOT language too (that's the -dotoutput option, we'll get there π).
π OPTIONS π
-dotoutput <dir>β destination directory for DOT file output. if you specify this,jdepsgenerates one dot file per each analyzed archive, named<archive-file-name>.dot, listing the dependencies β plus a summary file namedsummary.dotlisting the dependencies among the archives. a whole lil family of files π₯Ή-s,-summaryβ prints the dependency summary only. just the highlights, keep it short bestie π-v,-verboseβ prints all class-level dependencies. the full tea β-verbose:packageβ prints package-level dependencies, but excludes dependencies within the same archive. we're not counting self-love as a dependency π-verbose:classβ prints class-level dependencies, also excluding dependencies within the same archive.-cp <path>,-classpath <path>β specifies where to find class files. also, see Setting the Class Path. (iykyk)-p <pkg name>,-package <pkg name>β finds dependencies in the specified package. you can pass this option multiple times for different packages, stack 'em up π heads up: the-pand-eoptions are mutually exclusive β they do not coexist, periodt.-e <regex>,-regex <regex>β finds dependencies in packages matching the specified regular expression pattern. and yeah, same rule:-pand-eare mutually exclusive π₯-include <regex>β restricts analysis to classes matching pattern. this one filters the list of classes to be analyzed. it can be used together with-pand-e, which apply the pattern to the dependencies. teamwork makes the dream work π«Ά-jdkinternalsβ finds class-level dependences in JDK internal APIs. by default it analyzes all classes specified in the-classpathoption and in input files, unless you specified the-includeoption. you cannot use this option with the-p,-e, and-soptions β that's a hard no, bestie π«
β οΈ Warning: JDK internal APIs may not be accessible in upcoming releases. so like... don't get too attached π
-P,-profileβ shows the 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. very "surface level only" of her π-R,-recursiveβ recursively traverses all dependencies. she goes deep. no chill. π-versionβ prints version information. the classic.-h,-?,-helpβ prints the help message forjdeps. when in doubt,-hit out π
π EXAMPLES π
analyzing the dependencies of Notepad.jar
$ jdeps demo/jfc/Notepad/Notepad.jar
demo/jfc/Notepad/Notepad.jar -> /usr/java/jre/lib/rt.jar
<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
use the -P or -profile option to show on which profile that Notepad depends π
$ jdeps -profile demo/jfc/Notepad/Notepad.jar
demo/jfc/Notepad/Notepad.jar -> /usr/java/jre/lib/rt.jar (Full JRE)
<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
analyzing the immediate dependencies of a specific class in a given classpath
for example, the com.sun.tools.jdeps.Main class in the tools.jar file:
$ jdeps -cp lib/tools.jar com.sun.tools.jdeps.Main
lib/tools.jar -> /usr/java/jre/lib/rt.jar
com.sun.tools.jdeps (tools.jar)
-> java.io
-> java.lang
use the -verbose:class option to find class-level dependencies, or use the -v or -verbose option to include dependencies from the same JAR file π
$ jdeps -verbose:class -cp lib/tools.jar com.sun.tools.jdeps.Main
lib/tools.jar -> /usr/java/jre/lib/rt.jar
com.sun.tools.jdeps.Main (tools.jar)
-> java.io.PrintWriter
-> java.lang.Exception
-> java.lang.Object
-> java.lang.String
-> java.lang.System
use the -R or -recursive option to analyze the transitive dependencies of the com.sun.tools.jdeps.Main class. this is where it gets spicy π₯
$ jdeps -R -cp lib/tools.jar com.sun.tools.jdeps.Main
lib/tools.jar -> /usr/java/jre/lib/rt.jar
com.sun.tools.classfile (tools.jar)
-> java.io
-> java.lang
-> java.lang.reflect
-> java.nio.charset
-> java.nio.file
-> java.util
-> java.util.regex
com.sun.tools.jdeps (tools.jar)
-> java.io
-> java.lang
-> java.nio.file
-> java.nio.file.attribute
-> java.text
-> java.util
-> java.util.jar
-> java.util.regex
-> java.util.zip
/usr/java/jre/lib/jce.jar -> /usr/java/jre/lib/rt.jar
javax.crypto (jce.jar)
-> java.io
-> java.lang
-> java.lang.reflect
-> java.net
-> java.nio
-> java.security
-> java.security.cert
-> java.security.spec
-> java.util
-> java.util.concurrent
-> java.util.jar
-> java.util.regex
-> java.util.zip
-> javax.security.auth
-> sun.security.jca JDK internal API (rt.jar)
-> sun.security.util JDK internal API (rt.jar)
javax.crypto.spec (jce.jar)
-> java.lang
-> java.security.spec
-> java.util
/usr/java/jre/lib/rt.jar -> /usr/java/jre/lib/jce.jar
java.security (rt.jar)
-> javax.crypto
generating dot files of the dependencies of the Notepad demo
$ jdeps -dotoutput dot demo/jfc/Notepad/Notepad.jar
jdeps will create one dot file for each given JAR file, named <filename>.dot, in the dot directory specified in the -dotoutput option β and also a summary file named summary.dot that will list the dependencies among the JAR files π§
$ cat dot/Notepad.jar.dot
digraph "Notepad.jar" {
// Path: demo/jfc/Notepad/Notepad.jar
"<unnamed>" -> "java.awt";
"<unnamed>" -> "java.awt.event";
"<unnamed>" -> "java.beans";
"<unnamed>" -> "java.io";
"<unnamed>" -> "java.lang";
"<unnamed>" -> "java.net";
"<unnamed>" -> "java.util";
"<unnamed>" -> "java.util.logging";
"<unnamed>" -> "javax.swing";
"<unnamed>" -> "javax.swing.border";
"<unnamed>" -> "javax.swing.event";
"<unnamed>" -> "javax.swing.text";
"<unnamed>" -> "javax.swing.tree";
"<unnamed>" -> "javax.swing.undo";
}
$ cat dot/summary.dot
digraph "summary" {
"Notepad.jar" -> "rt.jar";
}
π SEE ALSO π
javap(1)β go say hi to her too, she's iconic π
okay that's the whole page bestie, you're officially a jdeps girlie now π
β¨
this lil masterpiece is from JDK 8, dated 21 November 2013 β vintage but still slaying π
π¦ where this page comes from
- arch rolling: jdk8-openjdk 8.504.u01-1 Β· LicenseRef-Java
- Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms