You're in a terminal, or your AI coding agent is, and you need the Javadoc for one method in a dependency. The usual options: dig through an HTML javadoc tree, open an IDE just to hover, or unzip a -sources.jar and grep for the comment.
jdx is an open-source CLI (and MCP server) that answers IDE questions about JVM jars. One of those questions is "what does the Javadoc say?", and jdx doc prints the answer as plain text, plus the file and line range it came from.
A class comment from a Maven coordinate
$ jdx doc com.google.gson.Gson --coord com.google.code.gson:gson:2.14.0 --fetch com.google.gson.Gson source: gson-2.14.0-sources.jar · com/google/gson/Gson.java:49-134 This is the main class for using Gson. Gson is typically used by first constructing a Gson instance and then invoking #toJson(Object) or Class) methods on it. Gson instances are Thread-safe so you can reuse them freely across multiple threads. … --fetch allows a download when the coordinate isn't already in ~/.gradle/caches or ~/.m2, and it also pulls the -sources.jar when the repository publishes one. Without the flag, nothing is downloaded. Long comments are capped by --max-lines (default 200).
One method, without guessing which overload
Gson#toJson has 8 overloads. jdx won't pick one for you: it exits 2 and prints every candidate as a reference you can paste.
$ jdx doc 'com.google.gson.Gson#toJson' --coord com.google.code.gson:gson:2.14.0 --fetch ambiguous: 8 candidates for com.google.gson.Gson#toJson com.google.gson.Gson#toJson(com.google.gson.JsonElement) com.google.gson.Gson#toJson(java.lang.Object) … hint: re-run with one of the refs above $ jdx doc 'com.google.gson.Gson#toJson(Object)' --coord com.google.code.gson:gson:2.14.0 --fetch com.google.gson.Gson#toJson(java.lang.Object) source: gson-2.14.0-sources.jar · com/google/gson/Gson.java:527-541 This method serializes the specified object into its equivalent JSON representation. … @param src the object for which JSON representation is to be created @return JSON representation of src. @see #toJson(Object, Appendable) @see #toJson(Object, Type) Block tags like @param and @return stay; known HTML tags are stripped. Quote references in your shell, since #, ( and $ are shell syntax.
Inherited comments and the JDK
A method with no comment of its own falls back to the nearest documenting supertype, and the source: line says so:
$ jdx doc 'java.util.Collections$UnmodifiableMap#get(Object)' java.util.Collections$UnmodifiableMap#get(java.lang.Object) source: src.zip · java.base/java/util/Map.java:217-240 (inherited from java.util.Map) Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. … The running JDK is on the classpath by default, read from its lib/src.zip. --no-inherited keeps only the comment written on that exact symbol, and --raw prints the comment verbatim.
Pair it with members and body
jdx members --with-doc adds the first sentence of each member's Javadoc to the listing, and jdx body --with-doc puts the comment beside the method body. That's usually all an agent needs to call an unfamiliar API correctly, in two small answers instead of a page of HTML.
For AI agents
The same command is the jdx_doc tool in jdx mcp. jdx setup --agent claude-code --scope project (or cursor, codex, copilot, cline and others) wires it up. Every command also takes --json.
jdx needs Java 21+, runs on Linux, macOS and Windows, and is Apache-2.0. Install with one line:
curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash Full guide with every example (each one runs when the docs are built): Read Javadoc from a jar in the terminal.
