Well this blog entry is a result of my search for a "JD-GUI command line". JD-GUI is an awesome and fast Java Decompiler that supports Java 5 and current compilers including the following:
jdk1.1.8, jdk1.3.1, jdk1.4.2, jdk1.5.0, jdk1.6.0, jdk1.7.0, jrockit90_150_06, jikes-1.22, harmony-jdk-r533500, and Eclipse Java Compiler v_677_R32x, 3.2.1 release.
I was using JAD, a command line Java decompiler for long which is very old, doesn't support Java 5 and currently a dead project. Command line decompilation for JD-GUI is a highly requested feature but it's not implemented because its author want it that way. The command line feature of current JD-GUI allows anyone to give an input file so that the decompiled output opens up in the GUI. But developers wanted a complete command line version that allows batch decompilation without the GUI for many automation projects.
My search ended at: https://github.com/nviennot/jd-core-java/
JD-IntelliJ is a plug-in for IntelliJ IDEA, initiated by Brice Dutheil. A little hack around this will help us to create the command line version o JD-GUI. It fakes the interfaces of the IDE, and provides access to JD-Core.
After playing around a while and fixing some bugs with the code, i was able to generate a java executable that allows command line decompilation of jar files.
After a few Bug Fixes: https://github.com/ajinabraham/jd-core-java
If you want the compiled binary, download it from here :
https://drive.google.com/file/d/0B_Ci-1YbMqshQldsRlFwaUZXUVE/view?usp=sharing
jdk1.1.8, jdk1.3.1, jdk1.4.2, jdk1.5.0, jdk1.6.0, jdk1.7.0, jrockit90_150_06, jikes-1.22, harmony-jdk-r533500, and Eclipse Java Compiler v_677_R32x, 3.2.1 release.
I was using JAD, a command line Java decompiler for long which is very old, doesn't support Java 5 and currently a dead project. Command line decompilation for JD-GUI is a highly requested feature but it's not implemented because its author want it that way. The command line feature of current JD-GUI allows anyone to give an input file so that the decompiled output opens up in the GUI. But developers wanted a complete command line version that allows batch decompilation without the GUI for many automation projects.
My search ended at: https://github.com/nviennot/jd-core-java/
JD-IntelliJ is a plug-in for IntelliJ IDEA, initiated by Brice Dutheil. A little hack around this will help us to create the command line version o JD-GUI. It fakes the interfaces of the IDE, and provides access to JD-Core.
After playing around a while and fixing some bugs with the code, i was able to generate a java executable that allows command line decompilation of jar files.
After a few Bug Fixes: https://github.com/ajinabraham/jd-core-java
If you want the compiled binary, download it from here :
https://drive.google.com/file/d/0B_Ci-1YbMqshQldsRlFwaUZXUVE/view?usp=sharing
Usage: java -jar jd-core.jar <input jar file> <output dir>
Thank you! This was exactly what I was looking for.
ReplyDeleteI wrote a little shell-script and than started a massiv decompile session:
#!/bin/bash
if [ $# == 2 ]
then
for file in $1/*.jar; do
echo "jar: "${file}
java -jar ~/bin/jd-core.jar ${file} $2
done
else
echo 'Usage: jd.sh '
echo 'decompile jar files in src-dir to dest-dir'
fi
Hi Ajin,
ReplyDeleteI tried to decompile my jar using above command i.e. java -jar ./jd-core.jar $1 $2.
But getting exception:
java.lang.NullPointerException
at jd.gj.a(Unknown Source)
at jd.gj.a(Unknown Source)
at jd.gi.b(Unknown Source)