Decompiling Class Files with jadx: A Step-by-Step Guide
Reverse engineering Java applications is a powerful skill for debugging, learning, or analyzing code. With tools like jadx, decompiling Java bytecode, DEX, JAR, and APK files becomes straightforward. This guide walks you through the process of using jadx to inspect and decompile Java applications efficiently.
Why Decompile Java Applications?
Java applications are compiled into bytecode (.class files) for execution on the Java Virtual Machine (JVM). Android apps, meanwhile, use Dalvik Executable (DEX) files. Decompiling these files allows you to recover readable Java source code, making it invaluable for:
- Debugging obfuscated code
- Learning from existing projects
- Reverse-engineering third-party libraries
Getting Started with jadx
Installing jadx
jadx is open-source and available for Linux, Windows, and macOS. To install:
- Clone the GitHub repository:
git clone https://github.com/skylot/jadx.git - Navigate to the jadx directory:
cd jadx - Build the project:
./gradlew build - Add the build directory to your PATH:
export PATH=~/jadx/build/jadx/bin:$PATH
Running jadx: Command-Line and GUI
jadx offers two modes:
- Command-line tool: Use
jadxfor quick decompilation tasks. - Graphical interface: Launch
jadx-guifor an interactive experience.
Decompiling Java Class Files
Example: Hello World Application
Consider a simple Java app with two classes: ExampleForJadx (main method) and ExampleForJadxUtils (utility functions). To decompile the .class file:
jadx ExampleForJadx.classjadx will generate a folder containing the recovered source code and package structure. For instance:
ExampleForJadx/
├── resources
└── sources
└── com
└── baeldung
└── exampleforjadx
└── ExampleForJadx.javaDecompiling JAR and APK Files
Decompiling a JAR File
To decompile an entire Java application stored in a JAR file:
jadx ExampleForJadx.jarThe output includes the original class files, resources, and manifest. Example structure:
ExampleForJadx/
├── resources
│
├── com
│
│
└── baeldung
│
│
└── exampleforjadx
│
│
├── ExampleForJadx.class
│
│
└── ExampleForJadxUtil.class
│
├── exampleforjadx
│
│
└── HelloWorld.txt
│
└── META-INF
│
└── MANIFEST.MF
└── sources
└── com
└── baeldung
└── exampleforjadx
├── ExampleForJadx.java
└── ExampleForJadxUtil.javaDecompiling an APK File
Android APKs use DEX files. jadx automatically handles DEX-to-Java conversion. Simply run:
jadx app.apkThe tool will extract resources, manifest, and decompile DEX files into readable Java code.
Practical Tips for Effective Decompilation
- Use
jadx-guito explore decompiled code interactively. - Look for obfuscation in third-party apps—tools like ProGuard can obscure code.
- Combine jadx with JD-GUI for faster analysis of small files.
Conclusion: Mastering jadx for Reverse Engineering
jadx is an essential tool for Java and Android developers. Whether you’re debugging legacy code or studying open-source projects, its ability to decompile class, JAR, DEX, and APK files makes it indispensable. Start experimenting with jadx today to unlock deeper insights into Java applications.
Ready to dive in? Clone jadx from GitHub and follow this guide to decompile your first Java app. Need further help? Explore our eBooks on Java tools for advanced techniques.








