You get a NoClassDefFoundError, a duplicate-class warning, or a crash log that names com.something.FooHandler and you need one answer: which jar ships that class?

The classic answer is a loop:

for j in libs/*.jar; do unzip -l "$j" | grep -q 'FooHandler' && echo "$j"; done 

It works, but it greps zip entry paths, not class names, it misses nested classes unless you remember the $, and it gets slow once you point it at a full modpack or a Gradle cache.

jdx is a small command-line tool (and MCP server) that reads class names from bytecode and prints the jar on the same line. Here is the whole workflow; the full guide with real output is at Find which JAR contains a class.

One exact name: jdx resolve

jdx resolve FooHandler --jars 'libs/*.jar' --no-jdk 

resolve accepts a simple name, a dotted or binary name, a Type#member, or a package. Each row is kind, canonical name, and the artifact's file name. If the same simple name lives in two jars you get two rows, which is exactly what you want when you are hunting a duplicate class. A miss exits 1 and prints did-you-mean suggestions; several candidates exit 0 and list every one.

Real run against Gson from Maven Central:

$ jdx resolve JsonParser --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk search results for 'JsonParser' class com.google.gson.JsonParser gson-2.14.0.jar 

Two details that save time:

  • Quote the glob. --jars 'libs/*.jar' lets jdx expand it; an unquoted shell expansion is rejected (exit 3) instead of silently doing the wrong thing.
  • --no-jdk keeps JDK classes out of the answer. Leave it off and you can ask the JDK too: jdx resolve HashMap answers java.base.

A partial name: jdx search

When you only remember part of the name:

jdx search '*Http*Client' --kind class --jars 'libs/*.jar' --no-jdk jdx search HMap --kind class # camel humps find HashMap 

Globs, case-insensitive substrings, camel humps, --regex, and --fuzzy (retries a miss within two edits). --in 'app*.jar' narrows to artifacts whose file name matches.

What is inside a jar: jdx tree and jdx ls

$ jdx tree 'gson*' --depth 2 --counts --coord com.google.code.gson:gson:2.14.0 --fetch --no-jdk package tree for 'gson*' gson-2.14.0.jar com (221 types) com.google (221 types) com.google.gson (221 types) 

jdx ls com.google.gson.stream ... then lists every type in that package, one per line, with its jar.

The Minecraft case: which mod ships this class?

This is where I use it most. A crash report names a class and you have 150 jars in mods/:

jdx resolve SomeMixinTarget --jars 'mods/*.jar' --no-jdk jdx search '*Compat*' --kind class --jars 'mods/*.jar' --no-jdk 

You get the mod jar's file name next to each hit, so "which mod adds this class" or "which two mods both bundle this library" is one command. Honest caveats: jdx does not remap. A mod's own classes keep their names, but Minecraft classes appear in whatever namespace the jar was built with. For readable Minecraft names in a dev environment, pass the mapped jar Loom already produced with --jars. The Minecraft mods guide covers that setup.

Maven coordinates without a project

--coord group:artifact:version resolves from ~/.gradle/caches and ~/.m2 first; add --fetch to allow a checksum-verified download. Inside a Gradle or Maven project, jdx discovers dependency jars from the caches without running the build.

Next step

Once you know the class and its jar, jdx members and jdx body show its API and one method's code (decompiled with Vineflower and labelled when there is no sources jar). That is covered in Read and decompile a JAR from the terminal.

Every command takes --json, and the same lookups are exposed as MCP tools (jdx mcp), so an AI coding agent can ask "which jar has this class" instead of guessing.

jdx is Apache-2.0, needs Java 21+, and runs on Linux, macOS and Windows:

curl -fsSL https://raw.githubusercontent.com/MohammadMD1383/jdx/main/install-release.sh | bash 

Docs: https://mohammadmd1383.github.io/jdx/ · Source: https://github.com/MohammadMD1383/jdx