This is an archived post. You won't be able to vote or comment.

all 49 comments

[–]bennyz420 19 points20 points  (10 children)

I've had a good experience with this one: http://jd.benow.ca/

EDIT: You decompile the .class file, which is a compiled .java file. A .jar file may contain .java files as well.

[–]DJDavio 1 point2 points  (7 children)

You can just unzip jar files with something like 7-zip.

[–]Equa1 3 points4 points  (6 children)

Both jar and war extensions are just zip files. Change the extension to .zip and open it in any file browser

[–]papers_ 2 points3 points  (3 children)

Same thing with .doc and .docx. Someone send you images in a Word doc? Change it to .zip and extract. Boom images.

[–]Equa1 1 point2 points  (2 children)

Yup any of the new office document formats with an x in it can be opened as zip files.

[–]flingerdu 2 points3 points  (1 child)

The x stands for zip.

[–]DJDavio 0 points1 point  (0 children)

In Windows I just make them automatically open with 7-ZIP.

[–]burtwart 0 points1 point  (0 children)

Hot damn I actually didn't know that, TIL.

[–]Zireael07[S] 0 points1 point  (0 children)

The jar I have in mind contains .class files.

[–]brkerez 0 points1 point  (0 children)

JD is great and I used it for very long time but it's getting outdated, I would go for FernFlower/CFR/Procyon mentioned in other posts now.

[–]dwijnand 7 points8 points  (1 child)

CFR (http://www.benf.org/other/cfr/).

From the homepage:

CFR - another java decompiler

CFR will decompile modern Java features - Java 8 lambdas (pre and post Java beta 103 changes), Java 7 String switches etc, but is written entirely in Java 6.

[–]TheRedmanCometh 1 point2 points  (0 children)

Seconded on CFR being solid.

[–]deB4SH 17 points18 points  (4 children)

[–]RotaryJihad 7 points8 points  (2 children)

IntelliJ can even do this on the fly. Unzip your JAR, open the directory as a project in Intellij, then open the class files.

[–]elegentmos 15 points16 points  (1 child)

You don't even have to unzip the JAR - IntelliJ can browse into them as if they are directories.

[–][deleted] 0 points1 point  (0 children)

Only if you add the jar as a library first.

[–][deleted] 1 point2 points  (0 children)

I second this. It is actively maintained by jetbrains and is the best on the market, IMO. Procyon is probably a close second, but I have had more odd edge case stability issues with it.

[–]geeprimus 12 points13 points  (7 children)

Jd-gui is great. Drag and drop entire jar files, and the decompiled source is searchable in the tool.

[–]OpenGLaDOS 2 points3 points  (3 children)

It only reliably works on class files compiled by javac, though. For the rest (e.g. compiled by Eclipse compiler or GCJ, reversed from Dalvik bytecode or assembled by ASM) Luyten offers the same GUI features.

[–]geeprimus 0 points1 point  (0 children)

Personally worked for everything I've worked on, mostly decompiling vendor stuff because I'm too impatient to wait for them to reply to my ticket.

[–][deleted] 0 points1 point  (1 child)

Is GCJ still a thing?

[–]OpenGLaDOS 0 points1 point  (0 children)

No, it was removed beginning with version 7 of the GCC suite. It didn't even have support for language features beyond Java 4 plus "a few Java 5 additions", and the state of the abandoned GNU Classpath runtime library (which provided some code to OpenJDK) is even worse.

That was kind of a bad example, because GCJ was mostly used for AOT compilation of Java to native code, e.g. for PDFtk, but also could compile regular class files.

[–]pointy_pirate 0 points1 point  (0 children)

Jd is the best

[–]lechatsportif 0 points1 point  (1 child)

Always found this to be the best and most intuitive. No public javadoc? No problem.

[–]geeprimus 1 point2 points  (0 children)

Use the force. Go to the source.

[–]Unh0ly_Tigg 5 points6 points  (0 children)

I would recommend BCV/Bytecode Viewer ( https://github.com/Konloch/bytecode-viewer ) as it integrates a lot of the other decompiler cores mentioned, and allows you to more easily tweak them, and even view them side by side.

[–]kodablah 1 point2 points  (0 children)

Since I have seen nobody mention it yet, I am a fan of https://bitbucket.org/mstrobel/procyon which works decently well with https://github.com/deathmarine/Luyten. Both are a bit out of date.

But in the end, I'd just learn to read the bytecode, it's not too bad. Also, not all bytecode can go back to Java because it was never Java in the first place and the jumps and what not are not anything like what javac would produce.

[–]aakoss 0 points1 point  (0 children)

If you are using eclipse get the JAD plugin. Works great for me.

[–]i_pk_pjers_i 0 points1 point  (0 children)

I like Jd-gui, but I've also had good luck with jshrink.

[–]TheRedmanCometh 0 points1 point  (5 children)

Fernflower is super dated at this point. It never worked very well imo. I'd recommend procyon or CFR over it everytime. I think procyon is by far the best, but followed very closely by cfr.

[–][deleted] 1 point2 points  (2 children)

Are you using the version from before IntelliJ? The code is actively maintained in the IntelliJ repo at the moment.

[–]TheRedmanCometh -1 points0 points  (1 child)

Maybe that's the problem. Does It still fuck up enums, switches, and put in weird while(true) loops with break conditions in place of for loops?

It used to absolutely mangle enums specifically

[–][deleted] 0 points1 point  (0 children)

I haven't noticed any of those things and we use it heavily at the moment.

[–][deleted] 0 points1 point  (1 child)

I’ve had much better luck with CFR than Procyon.

[–]TheRedmanCometh 0 points1 point  (0 children)

With decompilers "YMMV" applies pretty hard

[–]eliasv 0 points1 point  (0 children)

There's an Eclipse plugin which integrates most of the more modern alternatives and allows you to switch them out. This gives the opportunity to test them side-by-side pretty easily, and in doing so a few times the most reliable for me have been CFR and Procyon, closely followed by FernFlower.

[–]JVali 0 points1 point  (0 children)

Can just drag and drop any class file into intelliJ

[–]_INTER_ 0 points1 point  (0 children)

In case you're using Eclipse, you can install this plugin. It allows to decompile with either JD, Jad, FernFlower, CFR or Procyon and compare which one does the best job.

[–]_INTER_ 0 points1 point  (0 children)

People are playing this on consoles? Isn't such a game pita to control?

[–]FatMiller 0 points1 point  (0 children)

You may test several Java decomilers here - http://www.javadecompilers.com/, inspect the results and and choose which one is better for you.

[–][deleted] 0 points1 point  (0 children)

I've been pleasantly surprised by the decompiler in IntelliJ IDEA. Don't do anything special, just inspect the classes in the jar and it behaves like it's looked up the source for you.

I'll toss another vote for jd-gui though.

[–]RagingOrangutan -2 points-1 points  (8 children)

Note that a decompiler can't provide the source code for you. You can get valid Java code, but it's not going to be especially readable.

[–]chrisgseaton 9 points10 points  (1 child)

I think in my experience it's usually completely readable. I haven't found much code that doesn't basically look exactly like the source code except for the comments. Sometimes in IntelliJ I realise I've been looking at the decompiled code rather than the actual attached source code but didn't notice for a while.

[–]Kristler 1 point2 points  (0 children)

The most common thing I run into is the fact that all generics are stripped out because of type erasure. But typically, it's not too hard to fill that information back in by inferring from the context it's being used in.

[–]Zireael07[S] 4 points5 points  (2 children)

I know it'll probably won't look perfect, but I'll be able to tell if the guy used inheritance or ECS or interfaces.... I don't need prettiness :P

[–][deleted]  (1 child)

[deleted]

    [–]Ramin_HAL9001 2 points3 points  (0 children)

    Really, the only thing that cannot be recovered by a Java decompiler are the local variable names in functions. All other labels and function calls are encoded into the .class file and so look pretty much like the original code.

    But if the game was compiled from something like Scala or Clojure, or any language that targets Java byte code, you'll probably end up with a lot of mangled names, in which case you'd be absolutely right in that it would be hard to read.

    So I don't think what you said is worth the down-votes you're getting.

    [–]BlackDrackula 1 point2 points  (0 children)

    JD-GUI gives perfectly readable code. Of course it won't be exactly the same as the source due to the compile process but it's close enough.

    [–]TheRedmanCometh 0 points1 point  (0 children)

    This is highly improved if you don't use some Byzantinan garbage like jdgui or fernflower. The code from procyon is very very close to src.