Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decompile a whole Jar file? [closed]

Does anyone know of a free decompiler that can decompile an entire Jar file instead of a single class? I have a problem with sub classes like name$1.class name$2.class name.class

like image 306
StoneHeart Avatar asked Mar 15 '09 02:03

StoneHeart


People also ask

Is it possible to decompile a JAR file?

If you're looking for an easy solution, download Windup and run it's command-line version on your . jar. It will decompile using FernFlower, with support up to Java 8 (jad only suports up to Java 1.3, JavaDecompiler up to Java 1.5 IIRC), with a fallback to Procyon if FernFlower fails.


2 Answers

2009: JavaDecompiler can do a good job with a jar: since 0.2.5, All files, in JAR files, are displayed.

http://java.decompiler.free.fr/sites/default/screenshots/screenshot1.png

See also the question "How do I “decompile” Java class files?".

The JD-Eclipse doesn't seem to have changed since late 2009 though (see Changes).
So its integration with latest Eclipse (3.8, 4.2+) might be problematic.

JD-Core is actively maintained.

Both are the result of the fantastic work of (SO user) Emmanuel Dupuy.


2018: A more modern option, mentioned in the comments by David Kennedy Araujo:

JetBrains/intellij-community/plugins/java-decompiler/engine

Fernflower is the first actually working analytical decompiler for Java and probably for a high-level programming language in general.

java -jar fernflower.jar [-<option>=<value>]* [<source>]+ <destination>  java -jar fernflower.jar -hes=0 -hdc=0 c:\Temp\binary\ -e=c:\Java\rt.jar c:\Temp\source\ 

See also How to decompile to java files intellij idea for a command working with recent IntelliJ IDEA.

like image 105
VonC Avatar answered Oct 23 '22 02:10

VonC


First of all, it's worth remembering that all Java archive files (.jar/.war/etc...) are all basically just fancy.zip files, with a few added manifests and metadata.

Second, to tackle this problem I personally use several tools which handle this problem on all levels:

  • Jad + Jadclipse while working in IDE for decompiling .class files
  • WinRAR, my favorite compression tool natively supports Java archives (again, see first paragraph).
  • Beyond Compare, my favorite diff tool, when configured correctly can do on-the-fly comparisons between any archive file, including jars. Well worth a try.

The advantage of all the aforementioned, is that I do not need to hold any other external tool which clutters my work environment. Everything I will ever need from one of those files can be handled inside my IDE or diffed with other files natively.

like image 37
Yuval Adam Avatar answered Oct 23 '22 02:10

Yuval Adam