How do I "decompile" Java class files?

Update February 2016:

www.javadecompilers.com lists JAD as being:

the most popular Java decompiler, but primarily of this age only. Written in C++, so very fast.
Outdated, unsupported and does not decompile correctly Java 5 and later

So your mileage may vary with recent jdk (7, 8).

The same site list other tools.

And javadecompiler, as noted by Salvador Valencia in the comments (Sept 2017), offers a SaaS where you upload the .class file to the cloud and it returns you the decompiled code.


Original answer: Oct. 2008

  • The final release of JSR 176, defining the major features of J2SE 5.0 (Java SE 5), has been published on September 30, 2004.
  • The lastest Java version supported by JAD, the famous Java decompiler written by Mr. Pavel Kouznetsov, is JDK 1.3.
  • Most of the Java decompilers downloadable today from the Internet, such as “DJ Java Decompiler” or “Cavaj Java Decompiler”, are powered by JAD: they can not display Java 5 sources.

Java Decompiler (Yet another Fast Java decompiler) has:

  • Explicit support for decompiling and analyzing Java 5+ “.class” files.
  • A nice GUI:

screenshot

It works with compilers from JDK 1.1.8 up to JDK 1.7.0, and others (Jikes, JRockit, etc.).

It features an online live demo version that is actually fully functional! You can just drop a jar file on the page and see the decompiled source code without installing anything.


There are a few decompilers out there... A quick search yields:

  1. Procyon: open-source (Apache 2) and actively developed
  2. Krakatau: open-source (GPLv3) and actively developed
  3. CFR: open-source (MIT) and actively developed
  4. JAD
  5. DJ Java Decompiler
  6. Mocha

And many more.

These produce Java code. Java comes with something that lets you see JVM byte code (javap).


I tried several, and Procyon seemed to work the best for me. It's under active development and supports many features of the latest versions of Java.

These are the others I tried:

  • CFR
    • Promising, but often failed method decompilation. I'll be keeping my eye on this one. Also actively developed with support for the latest Java features.
  • Krakatau
    • Takes a different approach in that it tries to output equivalent Java code instead of trying to reconstruct the original source, which has the potential of making it better for obfuscated code. From my testing it was roughly on par with Procyon, but still nice to have something different. I did have to use the -skip command-line flag so it wouldn't stop on errors. Actively developed, and interestingly enough it's written in Python.
  • JD-GUI
    • Worked, but Procyon's output was much better. Here's a page comparing Procyon output to the original and JD-GUI. JD-GUI is also available as an Eclipse plugin, which didn't work for me at all. Doesn't seem to be open source and development seems sporadic.
  • JAD
    • Worked, but only supports Java 1.4 and below. Also available as an Eclipse plugin. No longer under development.

To see Java source code check some decompiler. Go search for jad.

If you want to see bytecodes, just use javap which comes with the JDK.