Core Java

jadx Decompile Classes Tutorial

Reverse engineering compiled artifacts is an essential practice in debugging, interoperability, and security analysis. Tools such as jadx enable us to convert bytecode into readable Java source code across multiple formats, including Java class files, Android DEX files, JAR archives, and APK packages. This article presents a guide to decompiling these formats using jadx, an open-source decompiler that translates bytecode into readable Java source code.

1. Overview of jadx

jadx is an open source decompiler that provides both command-line and graphical interfaces for converting Android and Java bytecode into human-readable Java source code. It supports a wide range of input formats, including .class, .dex, .jar, and .apk, which makes it a versatile tool for reverse engineering tasks.

In addition to source code reconstruction, jadx can decode Android resources such as XML files and manifest configurations. It also offers features such as syntax highlighting and structured project navigation, enabling efficient analysis of large and complex codebases, particularly in Android applications.

2. Downloading jadx

Installation on macOS

macOS provides a straightforward installation method using Homebrew.

brew install jadx

This command installs jadx and configures it for system-wide usage.

Verify Installation

jadx --version
jadx-gui

The commands confirm that jadx is correctly installed and accessible from the terminal. The GUI command launches the graphical interface.

The Homebrew installation automatically manages dependencies and ensures that the executable is available in the system path. This eliminates the need for manual configuration.

Installation on Windows

On Windows systems, jadx is typically installed using the prebuilt archive. The installation process involves downloading the Windows release archive, extracting the ZIP file, and navigating to the bin directory, where users can execute the .bat files directly by double-clicking them.

Building jadx From Source

For advanced users, jadx can be built from source.

git clone https://github.com/skylot/jadx.git
cd jadx
./gradlew dist

On Windows:

gradlew.bat dist

After building, the executable scripts are located in:

build/jadx/bin/

Building from source allows customisation and access to the latest development features.

3. Decompiling Java Class Files

Java class files contain bytecode generated by the Java compiler. jadx can convert these files back into readable Java source code.

jadx -d output_class MyClass.class

This command instructs jadx to decompile the specified class file and place the generated source code into the output_dir directory. The -d option defines the destination directory, ensuring that all generated files are organised in a structured manner.

Output Structure:

output_class/
└── sources/
    └── com/jcg/example/
        └── MyClass.java

The output contains only the reconstructed source code because class files do not include additional resources.

4. Decompiling JAR Files

JAR files are archives that bundle multiple class files and resources. jadx can extract and decompile all contents in a single operation.

jadx app.jar

This configuration allows jadx to unpack the archive, process each class file, and reconstruct the source code. The output directory will contain a folder hierarchy that mirrors the original package structure, which simplifies navigation and analysis.

Output Structure:

output_jar/
├── sources/
│   └── com/example/
│       ├── Main.java
│       └── Utils.java
└── resources/
    └── META-INF/
        └── MANIFEST.MF

The structure mirrors the original package hierarchy and includes metadata such as the manifest file.

5. Using jadx GUI

APK files are Android application packages that contain DEX files, resources, and metadata. jadx can fully decode APK contents, including layouts and assets. jadx also provides a graphical interface that simplifies navigation and inspection of decompiled code.

jadx-gui app.apk

The graphical interface allows users to browse packages, view decompiled classes, and search within the codebase. It is very useful for large projects where manual navigation through directories would be inefficient. The GUI simplifies analysis of large applications by presenting the project structure in a tree format and enabling quick access to classes and resources.

6. Conclusion

In this article, the process of decompiling .class, JAR and APK files using jadx have been presented. The guide covered installation on macOS and Windows, building from source, and practical command usage to support effective reverse engineering and code analysis.

This article provided an overview of using Java jadx to decompile classes.

Omozegie Aziegbe

Omos Aziegbe is a technical writer and web/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button