Menu

Which JAR contains this class? Finding classes across libs/, mods/ and Maven deps from the terminal
📰

Which JAR contains this class? Finding classes across libs/, mods/ and Maven deps from the terminal

DEV Community: kotlin·Mohammad Mostafa Dastjerdi·13 days ago
#5O3glKZc
#devtokotlin#devto#dev#member#class
Long article (699 words) — no AI summary yet.
Reading 0:00
15s threshold

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

Enter fullscreen mode

Exit fullscreen mode

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

Enter fullscreen mode

Exit fullscreen mode

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.