Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch decompiling of Java files with JD-GUI

I'm looking for a program to batch decompile Java classes. I found JAD, but it didn't support some new features of Java, and the benefit of this program is that it can execute from command line and generate a *.java file automatically.

I also found JD-GUI. It supports most features of Java, but the shortcoming is that it can't do batch processing. You need to open the class file with the program and click save.

Is there a way to make JD-GUI do batch processing like JAD?

like image 535
MemoryLeak Avatar asked Sep 06 '09 00:09

MemoryLeak


People also ask

How do I decompile a Java file?

class without source default to Class Decompiler Viewer . Now, click on the class or methods, press F3 , and the plugin will automatically decompile the Java class.

What does JD-GUI do?

JD-GUI is a standalone graphical utility that displays Java source codes of “. class” files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields. JD-Eclipse is a plug-in for the Eclipse platform.


2 Answers

Command line decompilation for JD-GUI is a highly requested feature but it's not implemented yet. Perhaps you can use the following workaround in the meantime:

  1. jar (or zip) all the classes you want decompiled together.
  2. Launch JD-GUI and open your jar (zip) archive.
  3. Use "File" - "Save JAR Sources" menu option. It will decompile all classes from your archive and save their sources into another zip file.

I haven't seen any good open source JD-GUI alternatives with command-line support, unfortunately, so I think the above is as good as it gets for now.

like image 190
ChssPly76 Avatar answered Sep 19 '22 20:09

ChssPly76


I could recommend using Jad in conjuction with JadRetro - of course, it can't make Jad produce java generics but the decompiled source (including for Java 1.5+ classes) is functionally equivalent to the original (and back compilable in most cases).
Its use is simple:

jadretro *.class
jad .class

Notes:
1. JadRetro could be used in batch mode like this: jadretro ...
2. If you are using jad v1.5.8e (instead of the latest v1.5.8g) then "-c" option should be passed to jadretro (otherwise jad will refuse to decompile Java 1.5+ classes).

like image 43
ivmai Avatar answered Sep 18 '22 20:09

ivmai