Batch Decompiling Java Class Files with JAD CLI

To recursively decompile compiled Java bytecode back into source files across an entire directory tree, the jad command-line utility supports wildcard patterns combined with directory restoration flags.

Windows Environment Example

jad -r -o -ff -s java -d C:\projects\decompiled_src -space -nonlb -t 4 C:\build\output\**\*.class

Unix/Linux Environment Example

jad -r -o -ff -s java -d ./recovered_source -space -nonlb -t 2 ./target/classes/**/*.class

Core Flags for Batch Operations

  • -r: Reconstructs the original package directory hierarchy in the destination folder.
  • -o: Forces overwriting of existing files without prompting.
  • -ff: Places field declarations before method definitions.
  • -s <ext>: Sets the output file extension (e.g., java instead of the default jad).
  • -d <dir>: Specifies the root directory for generated source files.
  • -space: Inserts a space between control keywords (if, while, for) and their conditions.
  • -nonlb: Prevents automatic line breaks before opening braces.
  • -t <num>: Defines the number of spaces used for indentation.

Complete Command-Line Reference

The following parameters control decompilation behavior, output formatting, and identifier handling:

Flag Description
-a Embed JVM bytecode instructions as inline comments.
-af Use fully qualified class names within annotation comments.
-b Insert explicit braces for all control structures, even when optional.
-clear Reset all custom prefixes to their default state.
-dead Attempt to reconstruct unreachable or dead code branches.
-dis Operate strictly as a bytecode disassembler without generating Java syntax.
-f Output fully qualified names for all referenced types.
-i Include default initializer values for class fields.
-l<num> Truncate string literals to a maximum character length.
-lnc Preserve original source line numbers as comments.
-lradix<num> Format long integer literals using the specified base.
-nl Break string literals at newline characters.
-noconv Retain original bytecode identifiers without sanitizing them for Java compliance.
-nocast Omit implicit type casting operations.
-noclass Skip conversion of .class literal references.
-nocode Generate method signatures only, omitting implementation bodies.
-noctor Exclude compiler-generated empty constructors.
-nodos Bypass validation for DOS-formatted class files.
-nofd Allow duplicate field names without disambiguation.
-noinner Disable reconstruction of nested and inner classes.
-nolvt Ignore the Local Variable Table during symbol resolution.
-p Stream all output directly to standard output for piping.
-pa <pfx> Apply a custom prefix to all package declarations.
-pc <pfx> Prefix for synthetically named classes (default: _cls).
-pe <pfx> Prefix for unused exception variables (default: _ex).
-pf <pfx> Prefix for synthetically named fields (default: _fld).
-pi<num> Consolidate import statements using wildcard syntax after a threshold.
-pl <pfx> Prefix for synthetically named local variables (default: _lcl).
-pm <pfx> Prefix for synthetically named methods (default: _mth).
-pp <pfx> Prefix for synthetically named method parameters (default: _prm).
-pv<num> Merge consecutive field declarations of identical types onto a single line.
-radix<num> Render integer literals in octal (8), decimal (10), or hexadecimal (16).
-safe Insert explicit casts to resolve ambiguous method or field references.
-stat Print a summary count of processed classes, methods, and fields.
-t Use tab characters for indentation instead of spaces.
-v Enable verbose logging of method names during processing.
-8 Translate Unicode escape sequences into standard ANSI characters.
-& Merge standard error streams into standard output.

Tags: java decompilation jad CLI reverse-engineering

Posted on Fri, 08 May 2026 10:41:11 +0000 by Highlander