Sunday, June 10, 2012

Java Decompiler (Jad) : A Smart guide

Jad is a command line Java decompiler written by Pavel Kouznetsov,written for several plateform.
can be downloaded from

Installation is very easy,just extract the downloaded zip .
Set the environment variable path for your plateform here I am using windows.
After setting the path variable open the cmd to check the proper installation type jad on
command prompt,if every thing goes fine you will find the fallowing outupt.

To decompile single java class use the command
jad -sjava MyClass.class

To decompile Multiple java class use the command
jad -o -r -sjava -dsrc bin/**/*.class

Jadclipse plugin for Eclipse
Download the Jadclipse for eclipse from
Copy the extracted jars in the Eclipse plugin folder.
Restart the Eclipse and set the decompliler path as shown

Now your Eclipse is ready to decompile any java class whose source file is not provided with you,just press
F3 on the name of the class and see the magic.

Ant Build File to decompile all the classes inside the jar

<project name="Decompile_jars" default="main" basedir=".">

<taskdef resource="net/sf/antcontrib/"/>

<property name="jad" location="c:/program files/jad1.5.8/jad.exe"/>
<property name="unjar.dir" location="loc_unjar"/>

<target name="main">
        message="Please enter jar file name"

    <!-- clean temp dir -->
    <delete dir="${unjar.dir}"/>

    <!-- unpack jar file -->    
    <unjar src="${input.file}.jar" dest="${unjar.dir}"/>

    <!-- decompile all class files -->
    <exec executable="cmd.exe">
        <arg line="/c ${jad} -o -r -sjava -d${unjar.dir} ${unjar.dir}/**/*.class"/>
    <!-- create jar file -->
    <jar destfile="${input.file}_decompile.jar">
        <fileset dir="${unjar.dir}"

    <!-- clean temp dir -->
    <delete dir="${unjar.dir}"/>


Post a Comment