HOWTO · Java

How to Decompile Java Class

Learn how to inspect Java .class files and JARs with Eclipse, IntelliJ IDEA, command-line decompilers, and JD-GUI.

On this page

To inspect compiled Java code, open a standalone .class file in an IDE or decompiler, or browse a .jar archive with a tool that supports archives. Eclipse IDE with Enhanced Class Decompiler (ECD) and IntelliJ IDEA can display reconstructed source; JD-CLI and FernFlower offer command-line workflows, while JD-GUI provides a browsable interface. Decompilation helps explain behavior when source is unavailable, but it cannot restore the original source exactly: comments and formatting are absent from bytecode, and names or structure may differ.
Decompiling is one of the class-level topics in the Java Tutorial, in the classes and methods group.

Reasons for Decompiling a Java Class

A compiled .class file contains Java bytecode for a class. A .jar file is an archive that can contain class files, images, configuration, and other resources. You can list or extract an archive with ZIP tools; decompilation is useful when you want readable code for one of its compiled classes.

Developers commonly inspect compiled classes to understand a library, investigate behavior, or check what was packaged. Choose an IDE when you already work in one, a command-line decompiler when you need repeatable file processing, or JD-GUI when you want to browse classes interactively. You generally need access to the file and a tool that can read its format; the fact that a file is a JAR does not by itself mean it is permission-restricted.

Java Decompiler

A Java decompiler analyzes bytecode and reconstructs source-like Java code. The result is an approximation, not a recovery of the source project. The compiler normally removes comments and source formatting. Depending on compiler options and available debug metadata, local variable names and line information may also be absent. A JAR is an archive of files, whereas a .class file is an individual compiled class; a decompiler may accept either, depending on the tool.

For a quick inspection, use IntelliJ IDEA or Eclipse IDE. For a terminal workflow, use JD-CLI or FernFlower. For browsing a JAR and selecting classes in a window, use JD-GUI. The Java decompiler overview provides related tool context.

Decompile Java Class Using Eclipse IDE

Install the Enhanced Class Decompiler (ECD) plug-in from Eclipse Marketplace, then associate class files with its editor:

  • Open Help and choose Eclipse Marketplace. Search for Enhanced Class Decompiler and follow the installation prompts.
  • Open Window > Preferences, then choose General > Editors > File Associations.
  • Select the *.class file type. In the associated editors list, choose the ECD decompiler editor and set it as the default if you want class files to open there.
  • Apply the preference, then open a .class file in the Project or Package Explorer.

Menu labels can vary slightly between Eclipse releases. If the file opens in another editor, return to File Associations and check that the decompiler editor is selected for *.class files.

Decompile Java Class Using IntelliJ IDEA

IntelliJ IDEA can display decompiled source for class files it can resolve, including classes in libraries. Open the class from the Project view or navigate to the class by name; the IDE presents a reconstructed source view. This is useful for inspection without a separate decompiler setup. The displayed code is still derived from bytecode and is not the original source file.

Decompile Java Class Using Command Line

Command-line decompilers are useful when you want to process a known input file or archive. Install a compatible Java runtime and obtain the tool from its project. Check the usage instructions shipped with that particular release: command syntax, options, and accepted input forms can differ between builds. No tool-specific command is included here, because no invocation has been verified for the selected releases.

Use JD-CLI

JD-CLI is a command-line Java decompiler. Provide the executable and input paths, then use the output option documented by the release you downloaded. Check that release’s help or documentation for whether it accepts a standalone class, a JAR, or both, and where it writes reconstructed source. Download JD-CLI from intoolswetrust/jd-cli and follow the usage documentation for that build.

Use FernFlower

FernFlower is another Java decompiler. Supply the decompiler, a source class or archive, and a destination directory using the syntax documented for your build. Check whether that version accepts a standalone class as well as a JAR and whether it requires additional settings. Likewise, no verified FernFlower invocation is included here.

The FernFlower mirror contains project and build information. A source checkout may require a compatible Gradle setup to build; for routine inspection, use a packaged release when the project provides one. Build and decompiler commands depend on the selected release and local Java/Gradle installation, so they are not presented as verified execution steps here.

Decompile Java Class Using JD-GUI

JD-GUI is a graphical Java decompiler for opening class files and browsing classes in JAR archives. Download a compatible release from the JD-GUI project site. Open a .class file or JAR through the application’s file chooser, then select a class in the navigation pane to inspect its reconstructed source. The exact menus vary by release.

This complete Java program prints a greeting and is suitable for compiling before you open its class file in JD-GUI.

public class Example1 {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

Its standard output is:

Hello World

When you inspect the compiled class, JD-GUI may render the args parameter with a different name, such as paramArrayOfString, and omit any source comments. Comments and formatting are not stored in ordinary class bytecode. Debug metadata, when present, can retain some names or line information; using a debugger during compilation does not itself make a class more readable. Treat reconstructed code as a guide to behavior and consult the original source when exact comments, names, or project structure matter.