Home > Uncategorized > Howto decompile a complete jar-file

Howto decompile a complete jar-file

Download JAD and jadAlign. Unpack the zips and copy the two executables in a path-directory. Put this little shell-script in your path.

decompile_jar.sh

OLD_PWD=$PWD
mkdir src 2>/dev/null
cp $1 src/$1.zip
cd src/
unzip $1.zip
rm -f $1.zip
find . -name "*.class" -exec jad -r -s "jad" -lnc {} \;
find . -name "*.class" -exec rm -f {} \;
find . -name "*.jad"   -exec jadAlign {} `basename {} .jad`.java \;
find . -name "*.jad"   -exec rm -f {} \;
cd $OLD_PWD

Open a shell (under windows you can use cygwin), change to the directory where the jar-file can be found and call

decompile_jar.sh jar2decompile.jar

At the end you should have a new directory src with the decompiled and re-aligned java-sources.

Try it :)

Categories: Uncategorized Tags: , , , ,
  1. thomaswabner
    Wednesday, 27. August 2008 at 10:39 | #1

    Very nice and interesting! Thanks.

    Some hints and questions about the shell script.

    Why you need the “OLD_PWD” stuff? You can simple

    mkdir src
    cd src
    .. do anything
    cd ..

    The find command should also called with
    find -type f

    to aviod executing jad and the other tools to run on a directory.

    The mkdir can be used better with
    mkdir src > /dev/null 2>&1
    to also grab the stdout

  1. No trackbacks yet.
You must be logged in to post a comment.