Search code examples
javajardecompiling

How can I decompile many jars at once?


Well, I guess subject says it all :)

The ideal solution would find all jars within a certain folder (they might be in sub-folders), and write all the sources found into a single "src" directory, of course maintaing the package folders.

Concrete use case: decompile all Eclipse plugin jars


Solution

  • Download JAD Decompiler.

    • Unjar all your jar files (using the command jar xvf) to some directory. Let's call this ${unjar.dir}.

    • Create a directory for JAD to write out the decompiled sources. Let's call this ${target.dir}.

    • Execute the following command:

        jad -o -r -sjava -d${target.dir} ${unjar.dir}/**/*.class
    

    options are:

    -o       - overwrite output files without confirmation
    -r       - restore package directory structure
    -s <ext> - output file extension (default: .jad)