JAva Decompiler (Jad)

 
 
Jad is a command line Java decompiler written by Pavel Kouznetsov. It is free for non-commercial use, but since the version 1.5.6 it's no longer free for commercial use in other software products. It is written for several platforms, such as:
  • Windows 9x/NT/2000
  • Linux
  • OS/2
  • FreeBSD
  • Solaris
  • Mac
  • AIX
  • BeOS
The Jad decompiler can be downloaded from http://www.varaneckas.com/jad

Quick guides







Installing Jad 1.5.8e



Information
none

Operating system used
Windows XP Home Edition Version 5.1 SP 2

Software prerequisites
none

Procedure
  1. Download and unzip jadnt158.zip for Windows 9x/NT/2000 on Intel platform.

  2. The directory where jad.exe is located should be put in your system environment variable PATH.
    e.g.: PATH=..;C:\Tools\jad1.5.8;

  3. To start using jad the following can be entered in a DOS window:
    jad

    It displays a list of command line options and how to use jad. An overview of these options can be found in the table below.

    Usage: jad [option(s)] <filename(s)>

    Options Description
    -a generate JVM instructions as comments (annotate)
    -af output fully qualified names when annotating
    -b generate redundant braces (braces)
    -clear clear all prefixes, including the default ones
    -d <dir> directory for output files
    -dead try to decompile dead parts of code (if there are any)
    -dis disassembler only (disassembler)
    -f generate fully qualified names (fullnames)
    -ff output fields before methods (fieldsfirst)
    -i print default initializers for fields (definits)
    -l <num> split strings into pieces of max <num> chars (splitstr)
    -lnc output original line numbers as comments (lnc)
    -lradix <num> display long integers using the specified radix
    -nl split strings on newline characters (splitstr)
    -noconv don't convert Java identifiers into valid ones (noconv)
    -nocast don't generate auxiliary casts
    -noclass don't convert .class operators
    -nocode don't generate the source code for methods
    -noctor suppress the empty constructors
    -nodos turn off check for class files written in DOS mode
    -nofd don't disambiguate fields with the same names (nofldis)
    -noinner turn off the support of inner classes
    -nolvt ignore Local Variable Table entries (nolvt)
    -nonlb don't insert a newline before opening brace (nonlb)
    -o overwrite output files without confirmation
    -p send all output to STDOUT (for piping)
    -pa <pfx> prefix for all packages in generated source files
    -pc <pfx> prefix for classes with numerical names (default: _cls)
    -pe <pfx> prefix for unused exception names (default: _ex)
    -pf <pfx> prefix for fields with numerical names (default: _fld)
    -pi <num> pack imports into one line using .* (packimports)
    -pl <pfx> prefix for locals with numerical names (default: _lcl)
    -pm <pfx> prefix for methods with numerical names (default: _mth)
    -pp <pfx> prefix for method parms with numerical names (default:_prm)
    -pv <num> pack fields with the same types into one line (packfields)
    -r restore package directory structure
    -radix <num> display integers using the specified radix (8, 10, or 16)
    -s <ext> output file extension (default: .jad)
    -safe generate additional casts to disambiguate methods/fields
    -space output space between keyword (if, while, etc) and expression
    -stat show the total number of processed classes/methods/fields
    -t <num> use <num> spaces for indentation (default: 4)
    -t use tabs instead of spaces for indentation
    -v show method names while decompiling
    -8 convert Unicode strings into ANSI strings (ansi)
    -& redirect STDERR to STDOUT
  4. To decompile a single file, just type:
    jad -sjava HelloWorld.class
    Jad creates the file HelloWorld.java

  5. To decompile multiple class files, just type:
    jad -o -r -sjava -dsrc bin/**/*.class
    Jad decompiles all .class files located in all subdirectories of "bin" and creates output files in subdirectories of "src" according to package names of classes. For example, if file "bin/a/b/c.class" contains class "c" from package "a.b", then output file will have a name "src/a/b/c.java".

    Note: Read the Readme.txt which can be found in the jadnt158.zip file, it contains more information about the usage of Jad.

  6. An Ant script has been written to decompile all files in a jar file using the jad application. See script build_demo8.xml.