CFR is a JVM bytecode decompiler - it will decompile modern Java features - up to and including much of Java 9, but is written entirely in Java 6, so will work.
CFR - another java decompiler
CFR will decompile modern Java features - up to and including much of Java 9, 10, 12 and beyond, but is written entirely in Java 6, so will work anywhere! (FAQ) - It'll even make a decent go of turning class files from other JVM langauges back into java!
To use, simply run the specific version jar, with the class name(s) you want to decompile (either as a path to a class file, or as a fully qualified classname on your classpath).(--help to list arguments).
Alternately, to decompile an entire jar, simply provide the jar path, and if you want to emit files (which you probably do!) add --outputdir /tmp/putithere
Download cfr
FAQ
FAQ is here
Contact / Updates
Feel free to drop me a line ([email protected]) if there's anything you think is particularly broken, bear in mind it's a work in progress (but I'd say on a par with others!) - Or if you want to know when an update is out, I've finally started announcing on twitter - (@LeeAtBenf)
Observations about syntactic sugar in compilation.
All of this stuff is documented (links where I find them); these are things I found particularly interesting while messing around with this.
.... and other observations.....
To do...
It's got a lot of things missing, which I'm messing with, as and when time makes itself available ;)
Change history0.146 (2019-07-19)
0.145 (2019-05-30)
0.144 (2019-05-09)
0.143 (2019-04-13)
0.142 (2019-04-09)
0.141 (2019-03-24)
0.140 (2019-03-05)
0.139 (2019-01-09)
0.138 (2018-12-14)
0.137 (2018-12-01)
0.136 (2018-11-24)
0.135 (2018-11-17)
0_134 (2018-11-04)
0_133 (2018-09-21)
0_132 (2018-07-06)
0_131 (2018-06-27)
0_130 (2018-06-04)
0_129 (2018-05-15)
0_128 (2018-04-30)
0_127 (2018-04-26)
...somehow, I manged to release an ancient version as 0_126! 0_127 is the real thing! Thanks jstokes for pointing out that bit of idiocy!
|
Last updated - see releases! |
Active1 year, 8 months ago
votes
What program can I use to decompile a class file? Will I actually get Java code, or is it just JVM assembly code?
On Java performance questions on this site I often see responses from people who have 'decompiled' the Java class file to see how the compiler optimizes certain things.
Peter Mortensen
14.4k1919 gold badges8888 silver badges117117 bronze badges
KipKip
69.2k7878 gold badges211211 silver badges250250 bronze badges
closed as off-topic by Jean-François Corbett, cimmanon, Paul Roub, Maroun, CRABOLOOct 25 '15 at 17:48
This question appears to be off-topic. The users who voted to close gave this specific reason:
- 'Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.' – Jean-François Corbett, cimmanon, Paul Roub, Maroun, CRABOLO
locked by Samuel Liew♦Jul 1 '18 at 23:10
This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.
Read more about locked posts here.
19 Answers
votes
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
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:
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.
VonCVonC
891k328328 gold badges28862886 silver badges34763476 bronze badges
votes
There are a few decompilers out there... A quick search yields:
- Procyon: open-source (Apache 2) and actively developed
- Krakatau: open-source (GPLv3) and actively developed
- CFR: open-source (MIT) and actively developed
And many more.
These produce Java code. Java comes with something that lets you see JVM byte code (javap).
billjamesdevbilljamesdev
12.9k66 gold badges4545 silver badges6868 bronze badges
votes
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.
MarkoMarko
22.5k1717 gold badges6767 silver badges106106 bronze badges
votes
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.
- 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
- 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.
8,05644 gold badges5656 silver badges6161 bronze badges
votes
I use JAD Decompiler.
There is an Eclipse plugin for it, jadeclipse. It is pretty nice.
sakanasakana
2,65355 gold badges2020 silver badges1919 bronze badges
votes
Janus TroelsenJanus Troelsen
14.5k66 gold badges102102 silver badges159159 bronze badges
votes
Soot is an option for newer Java code. At least it has the advantage of still being recently maintained...
Also, Java Decompiler is a decompiler with both a stand-alone GUI and Eclipse integration.
Lastly, Jdec hasn't been mentioned, though it's not as polished as other options.
Quinn TaylorQuinn Taylor
41.6k1515 gold badges103103 silver badges126126 bronze badges
votes
JD-GUI is really good. You could just open a JAR file and browse through the code as ifyou are working on an IDE. Good stuff.
Peter Mortensen
14.4k1919 gold badges8888 silver badges117117 bronze badges
G KumarG Kumar
votes
Here's a list of decompilers as of Feb 2015:
Procyon, open-source, https://bitbucket.org/mstrobel/procyon/wiki/Java%20Decompiler
CFR, free, no source-code available, http://www.benf.org/other/cfr/
JD, free for non-commercial use only, http://jd.benow.ca/
Fernflower, open-source, https://github.com/fesh0r/fernflower,
JAD – given here only for historical reason. Free, no source-code available, http://varaneckas.com/jad/Outdated, unsupported and does not decompile correctly Java 5 and later.
You may test above-mentioned decompilers online, no installation required and make your own educated choice.
Java decompilers in the cloud:http://www.javadecompilers.com/
Andrew RukinAndrew Rukin
votes
There are a few programs you can use. You will get the actual Java code, but sometimes the code will have been obfuscated so methods are named by one letter or number or a random mix of letters and numbers.
Mike PoneMike Pone
9,9081111 gold badges4646 silver badges5959 bronze badges
votes
Most decompilers for Java are based on JAD. It's a great tool, but unfortunately hasn't been updated for a while and does not handle Java 1.5+ classes very well. I have not seen any tools that will properly handle 1.5+ classes.
John MeagherJohn Meagher
12.9k1313 gold badges4848 silver badges5656 bronze badges
votes
Paulo GuedesPaulo Guedes
5,92155 gold badges3636 silver badges5454 bronze badges
votes
All of the JAD links listed so far far seem to be broken, so I found this site. Works great (for Linux, at least)! On Ubuntu 11.10 I had to download the static one for whatever reason.
kdazzlekdazzle
3,64733 gold badges1919 silver badges2525 bronze badges
votes
-
JAD is one that works and is simple.
-
Also, if you just want to see the methods, use javap.
4,4323333 gold badges114114 silver badges190190 bronze badges
votes
If you want to see how the Java compiler does certain things, you don't want decompilation, you want disassembly. Decompilation involves transforming the bytecode into Java source, meaning that a lot of low level information is lost, and if you're wondering about compiler optimization, this is probably the very information you're interested in.
Anyway, I happen to have written an open source Java disassembler. Unlike Javap, this works even on highly pathological classes, so you can see what obfuscation tools are doing to your classes as well. It can also do decompilation, though I wouldn't recommend it.
AntimonyAntimony
28.8k77 gold badges7474 silver badges8484 bronze badges
votes
JAD doesn't work for me (Ubuntu 11.10 issue) so I've moved forward and sopped on JODO. At least it has Open Java source code and been able to decompile my .class properly.
I recommend to check out 'branches/generic' branch first. The trunks is not stable.
alexander.boxalexander.box
votes
On IntelliJ IDEA platform you can use Java Decompiler IntelliJ Plugin. It allows you to display all the Java sources during your debugging process, even if you do not have them all. It is based on the famous tools JD-GUI.
naXanaXa
17k1111 gold badges109109 silver badges162162 bronze badges
vote
With AndroChef Java Decompiler you can decompile apk, dex, jar and java class-files. It's simple and easy. AndroChef JD is based on FernFlower. You can evaluate it in 10 free uses.
AndroChef supports Java language features like generics, enums and annotations. According to some studies, AndroChef Java Decompiler is able to decompile 98.04% of Java applications generated with traditional Java compilers - a very high recovery rate. It is simple but powerful tool that allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source.
naXanaXa
17k1111 gold badges109109 silver badges162162 bronze badges
vote
For OSX I recommend: jarzilla or JD-GUI
They both allow you to view jar,war,etc. file content and decompiles any class files inside of them.
Jarzilla: https://code.google.com/p/jarzilla/
JD-GUI: http://jd.benow.ca/
cjacksoncjackson
JD-GUI: http://jd.benow.ca/
1,40711 gold badge1212 silver badges2424 bronze badges
Not the answer you're looking for? Browse other questions tagged javadecompiler or ask your own question.
Comments are closed.
Author
Write something about yourself. No need to be fancy, just an overview.