Batch decompiling of Java files with JD-GUI
Asked Answered
B

6

34

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?

Brindle answered 6/9, 2009 at 0:53 Comment(0)
P
60

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.

Probability answered 6/9, 2009 at 1:23 Comment(4)
I've just discovered a CLI wrapper that uses JD - see github.com/nviennot/jd-core-javaEncephalon
This one looks promising too (actually it's a fork of the aforementioned one by Rob W) and it provides a library as well; but I haven't tested it yet though : github.com/kwart/jd-cmdDextrad
The homepage now has a drag and drop decompiler. You know what that means... ;)Jephthah
I don't have that option to Save JAR SourcesJarrett
A
3

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).

Alexipharmic answered 16/12, 2009 at 7:6 Comment(0)
L
1

It looks like you can launch the GUI with a whole bunch of libs at once using the command line and then CTRL+ALT+s/CTRL+w each tab to quickly save/close. It's not automated but tolerable when decompiling a pile of dependencies. (Note that the "^" is just a trick for doing multi-line commands in Windows.)

"c:\jd-gui-0.3.6.windows\jd-gui.exe" ^
 c:\my-libs\lib-a.jar ^
 c:\my-libs\lib-b.jar ^
 c:\my-libs\lib-c.jar ^
 c:\my-libs\lib-d.jar ^
 c:\my-libs\lib-e.jar
Livvyy answered 10/2, 2014 at 20:12 Comment(0)
C
1

File > Save all sources will save all files in the home directory.

Chrysler answered 12/5, 2018 at 8:17 Comment(0)
P
1

JD-GUI has the ability to batch export class files into .java file, zipped in a jar file.

however, this feature is not controlled by command line, but mouse clicking, this is not stable and sometimes will be stuck.

You can use jd-cli ( https://github.com/kwart/jd-cli/releases/tag/jd-cli-1.2.0 ).

  1. prepare your .jar file (containing classes )
  2. input: jd-cli target.jar -od jar_result -g ALL

and you will get a zipped java source code file.

Proposal answered 17/3, 2021 at 7:35 Comment(0)
A
0

The batch decompilation in command line was never added because a menu File -> Save All Sources already addresses this need.

For command line interface, kwart's jd-cli is now: https://github.com/intoolswetrust/jd-cli

Also a fork of jd-gui is available here: https://github.com/nbauma109/jd-gui-duo

Algonquian answered 30/3 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.