jdeps(1)

πŸ“¦ version 11.0.20.1.1, in centos-stream 9

πŸ’… 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 .class file
  • 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, jdeps generates one dot file per each analyzed archive, named <archive-file-name>.dot, listing the dependencies β€” plus a summary file named summary.dot listing 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 -p and -e options 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: -p and -e are 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 -p and -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 -classpath option and in input files, unless you specified the -include option. you cannot use this option with the -p, -e, and -s options β€” 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 for jdeps. when in doubt, -h it 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
  • centos-stream 9: java-11-openjdk-devel 1:11.0.20.1.1-2.el9 Β· ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib and ISC and FTL and RSA
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms