Classpath & workspaces
jdx answers from a classpath made of jars, class directories, source directories, Maven coordinates and the JDK. This guide covers every way to supply one — per command, as a named workspace, or by letting jdx discover your project.
The JDK is always there#
The running JDK's standard library is on every classpath (through jrt:/), paired with its
src.zip when the JDK ships one. Pass --no-jdk to leave it out.
Per-command flags#
| Flag | Adds |
|---|---|
--jars <path|glob|dir> |
jar files, class directories, folders of jars or globs (repeatable) |
--coord g:a:v |
a Maven artifact, plus its -sources.jar when available (repeatable) |
--fetch |
permission to download --coord artifacts; without it, only local caches are used |
--repo <url> |
an extra Maven repository, tried before Maven Central (repeatable) |
--no-jdk |
removes the JDK |
--release N |
multi-release feature to serve (--multi-release is the same flag). Omitted, the running JDK feature is used. 8 serves base entries only. Below 8 is a usage error. An explicit value stays in-process |
jdx usages additionally takes --src <dir> for project source directories.
Quote globs. --jars and --src each take one value per occurrence (jdx expands
the glob). An unquoted lib/*.jar is expanded by the shell into many argv tokens and
exits 3 with a hint to quote it — or repeat the flag per path:
jdx outline PluginUtils --jars "$HOME/.../lib/*.jar"
jdx outline PluginUtils --jars a.jar --jars b.jarA folder of jars. A folder that holds jars (.jar/.zip) and no .class
files, such as a Minecraft mods/ folder or a libs/ folder, reads as those jars,
including jars in subfolders (mods/client/, mods/1.21/). Symlinked folders are
not followed. To read only the top level, use the glob --jars 'mods/*.jar'. A
folder with .class files anywhere below it is still one class directory. Jars
nested inside a jar are opened too, see below.
Jar-in-jar libraries. A jar that bundles libraries as META-INF/jars/<lib>.jar
(Fabric) or META-INF/jarjar/<lib>.jar (Forge, NeoForge) is read together with those
nested jars. Each nested jar is its own root, so its classes, lang files and other
resources are searched like any other jar, and every hit is attributed to the outer jar
plus the nested path: mod.jar!META-INF/jars/lib.jar. Nested jars may nest again, to
three levels. They are read in memory and never extracted to disk. A ZIP64 nested jar is read like any other. A nested file that is
not a zip, or whose records are damaged, is skipped with a NESTED_JAR_SKIPPED warning that names
the outer jar and the nested path (skipped nested jar mod.jar!META-INF/jars/lib.jar: is not a zip);
the query still runs. When two mods bundle the same library, it appears once per
mod, which is what shows a duplicate. Use --in 'META-INF/jars' to look only at nested
jars, and --exclude 'META-INF/jars' (on commands that have --exclude) to leave them out. A Spring Boot fat jar's BOOT-INF/lib/<lib>.jar and a WAR's
WEB-INF/lib/<lib>.jar are read the same way (issue #186), and a hit reads
app.jar!BOOT-INF/lib/lib.jar. Use --in 'BOOT-INF/lib' or --exclude 'BOOT-INF/lib'
to narrow. The app's own classes under BOOT-INF/classes/ (WEB-INF/classes/ in a WAR)
keep their real names, so jdx show com.acme.App --jars app.jar finds them (issue #204).
The prefix is stripped only when the jar has BOOT-INF/lib/, WEB-INF/lib/ or a
Spring-Boot-Classes manifest attribute; resource paths are listed as stored.
A pasted classpath. One --jars value may be a classpath string, the parts joined
by : (; on Windows), as Gradle, mvn dependency:build-classpath or a launcher's
-cp prints it. It is split only when the whole value names no file and every part
exists, so a typo still exits 5 with no such artifact:
jdx search ModInitializer --jars "$(cat classpath.txt)"jdx ls com.google.gson.stream --coord com.google.code.gson:gson:2.14.0
types in package 'com.google.gson.stream'
package com.google.gson.stream (7 types)
class com.google.gson.stream.JsonReader gson-2.14.0.jar
class com.google.gson.stream.JsonReader$1 gson-2.14.0.jar
class com.google.gson.stream.JsonScope gson-2.14.0.jar
enum com.google.gson.stream.JsonToken gson-2.14.0.jar
class com.google.gson.stream.JsonWriter gson-2.14.0.jar
class com.google.gson.stream.MalformedJsonException gson-2.14.0.jar
… 2 more lines (run it yourself to see them all)Real output — this example ran against the current jdx when the page was built.
Finding which jar in that set contains a class is Find class in jar.
Passing the Loom-mapped Minecraft jar with the same --jars flag is
Inspect a Minecraft mod jar.
Maven coordinates#
Coordinates resolve from ~/.gradle/caches and ~/.m2 first — usually no download is
needed. With --fetch, a missing artifact is downloaded from Maven Central (or your --repo
mirrors) into the jdx cache, with checksum verification. Network access is opt-in per
invocation: jdx never downloads anything you did not ask for. The daemon, MCP server, and
HTTP API never fetch either — prime caches once cold with --fetch, or store explicit
--jars, before warm queries against stored --coord roots. MCP classpath tools also
accept jars and coord on the call (the same values as --jars and --coord, still
without a download) and discover for project auto-discovery when no stored workspace
is available. A stored workspace that exists still wins.
Named workspaces#
A workspace is a named, ordered classpath stored once and reused everywhere — the CLI, the MCP
server, the daemon, the HTTP API and jdx batch:
jdx ws create myapp --jars 'libs/*.jar' --src ./src --coord com.google.code.gson:gson:2.14.0
jdx ws add myapp build/classes/java/main
jdx ws list
jdx ws info myappSelect one per command with -w, per shell with JDX_WORKSPACE, or per machine with
jdx ws use:
jdx -w myapp usages 'com.example.Service#run()'
export JDX_WORKSPACE=myapp
jdx ws use myapp # default when neither -w nor JDX_WORKSPACE is set
jdx ws use --clearReference: Project and library configuration.
Explicit --jars / --coord flags always merge in front of the selected workspace.
Project auto-discovery#
With no workspace selected, jdx walks up from the working directory looking for
settings.gradle(.kts), build.gradle(.kts), pom.xml or .idea/. On a hit it assembles a
classpath from the project's own sources and build output plus the dependency jars it can find
in the Gradle and Maven caches. jdx never runs Gradle or Maven to do this; when it cannot pin
down the exact dependency set it says so with a PROJECT_DISCOVERY_FALLBACK warning.
Reading one class or method of a dependency on that classpath is
View source code of a Maven dependency.
Resolution order#
- Explicit flags (
--jars,--src,--coord). -w <name>.JDX_WORKSPACE, then thejdx ws usedefault.- Project auto-discovery.
- The JDK — always appended unless
--no-jdk.
When nothing resolves for a command that needs a classpath, jdx exits 4.
The index cache#
jdx keeps a persistent index keyed by content hash, so an unchanged jar is never re-read. Everything in it can be regenerated:
jdx cache info # location, size, artifact and class counts
jdx cache gc # evict artifacts no workspace references
jdx cache clear # wipe it; re-indexed on demandCache, config and runtime directories follow each OS's conventions (~/.cache/jdx and
$XDG_* on Linux, ~/Library/Caches on macOS, %LOCALAPPDATA% on Windows) and can be
overridden with JDX_* variables — the full table is in the
design specification.