Documentation menu

jdx doc

IDE equivalent: Quick documentation

Show the javadoc of a type or member: rendered plain text (HTML stripped, inline tags unwrapped, block tags kept) plus provenance (artifact, file, lines). Takes a type or member reference (e.g. 'com.example.Foo', "Gson#toJson(Object)"). Undocumented methods fall back to the nearest documenting supertype unless --no-inherited. Exits 1 when the symbol or its documentation is unknown, 2 when a member reference is ambiguous, 4 when the workspace cannot be resolved.

Usage#

jdx doc [<options>] <ref>

Example#

jdx doc 'com.google.gson.Gson#toJson(Object)' --coord com.google.code.gson:gson:2.14.0
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. This
method should be used when the specified object is not a generic type. This method uses {@link
Class#getClass()} to get the type for the specified object, but the getClass() loses
the generic type information because of the Type Erasure feature of Java. Note that this method
works fine if any of the object fields are of generic type, just the object itself should not
be of a generic type. If the object is of generic type, use Type)
instead. If you want to write out the object to a Writer, use {@link #toJson(Object,
Appendable)} instead.

@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)
warning MULTI_RELEASE_VARIANT: multi-release gson-2.14.0.jar serves version-specific variants for this JDK (21)
next: jdx show com.google.gson.Gson

Real output — this example ran against the current jdx when the page was built.

Options#

OptionDescription
--inheritedPull documentation from the nearest documenting supertype (the default; accepted for explicitness).
--no-inheritedOnly the symbol's own documentation (mutually exclusive with --inherited).
--rawServe the verbatim comment instead of rendered plain text.
--max-lines=<int>Maximum doc lines shown (default 200); the rest become a truncation footer.
--jars=<text>Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots.
-w, --workspace=<text>Use a named workspace (see jdx ws). Explicit --jars merge in front of it.
--no-jdkDo not include the running JDK's stdlib (included by default).
--coord=<text>Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace.
--repo=<text>Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL.
--fetchAllow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only.
--jsonEmit machine-readable JSON instead of human-readable text (same information, D-007).
--no-colorDisable ANSI colors even on a TTY (piped output is always plain).
--no-daemonForce in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1).
-h, --helpShow this message and exit

Arguments#

ArgumentDescription
<ref>Type or member reference to show the documentation of (full or short form).

Full help text#

Show jdx doc --help
jdx doc --help
Usage: jdx doc [<options>] <ref>

  Show the javadoc of a type or member: rendered plain text (HTML stripped, inline tags unwrapped, block tags kept) plus provenance (artifact, file, lines). Takes a type or member reference (e.g. 'com.example.Foo', "Gson#toJson(Object)"). Undocumented methods fall back to the nearest documenting supertype unless --no-inherited. Exits 1 when the symbol or its documentation is unknown, 2 when a member reference is ambiguous, 4 when the workspace cannot be resolved.

Options:
  --inherited             Pull documentation from the nearest documenting supertype (the default; accepted for explicitness).
  --no-inherited          Only the symbol's own documentation (mutually exclusive with --inherited).
  --raw                   Serve the verbatim comment instead of rendered plain text.
  --max-lines=<int>       Maximum doc lines shown (default 200); the rest become a truncation footer.
  --jars=<text>           Binary roots: jar files, class directories or globs (repeatable). Merge in front of the selected workspace's roots.
  -w, --workspace=<text>  Use a named workspace (see jdx ws). Explicit --jars merge in front of it.
  --no-jdk                Do not include the running JDK's stdlib (included by default).
  --coord=<text>          Maven coordinate root group:artifact:version (repeatable). Resolved from ~/.gradle/caches and ~/.m2 first; with --fetch, downloaded from Maven repositories into <cache-dir>/m2 with checksum verification. Merges in front of the workspace.
  --repo=<text>           Maven repository base URL for --coord fetches (repeatable, e.g. --repo https://repo.example.com/maven2). Tried in flag order before Maven Central, which stays last as the fallback. Must be an http(s) URL.
  --fetch                 Allow downloading --coord artifacts (and their -sources.jar) from Maven repositories (Central by default, --repo to add mirrors). Without it, coordinates resolve from the local caches only.
  --json                  Emit machine-readable JSON instead of human-readable text (same information, D-007).
  --no-color              Disable ANSI colors even on a TTY (piped output is always plain).
  --no-daemon             Force in-process execution: do not forward this query to the background daemon even when its socket answers (PROPOSAL.md §14.1).
  -h, --help              Show this message and exit

Arguments:
  <ref>  Type or member reference to show the documentation of (full or short form).

Real output — this example ran against the current jdx when the page was built.

Learn more#

Guide: Reading code · All commands

View as Markdown · Updated