LinuxCommandLibrary

javap

Disassemble Java class files

TLDR

Disassemble and list one or more .class files

$ javap [path/to/file1.class path/to/file2.class ...]
copy

Disassemble and list a built-in class file
$ javap java.[package].[class]
copy

Display help
$ javap -help
copy

Display version
$ javap -version
copy

SYNOPSIS

javap [options] classes...

Examples:
javap ClassName
javap -c ClassName.class
Use javap --help for complete options.

PARAMETERS

-c or --code
    Disassemble method code into readable bytecode

-classpath or -cp
    Specify directories or JARs to search for classes

-extdirs
    Override location of installed extensions

-help
    Display help message and exit

-J
    Pass flag directly to the JVM

-l
    Show line number and local variable tables

-modulepath
    Specify module path for locating classes

-p or --private
    Include private class members

-public
    Show only public class information (default)

-s
    Display internal type signatures

-sysinfo
    Print class file path, size, and timestamps

-table
    Format output as a table (default)

-verbose or -v
    Verbose mode: stack size, locals, and args

--release
    Use tools from specified JDK release

DESCRIPTION

Javap is a command-line utility bundled with the Java Development Kit (JDK) that disassembles compiled Java class files (.class) into human-readable format. It reveals the internal structure of classes, including fields, methods, constructors, and bytecode instructions executed by the Java Virtual Machine (JVM).

Primarily used by developers for reverse engineering, debugging optimized bytecode, verifying compiler output, or studying JVM behavior, javap defaults to showing package, protected, and public class members. Options allow customization: -c disassembles method code, -v provides verbose details like stack size and local variables, and -p exposes private elements.

It locates classes via classpaths, supports module paths for modern Java, and handles inner classes or lambdas. Essential for bytecode analysis, javap aids in performance tuning, security audits, and educational purposes without needing a full IDE.

CAVEATS

Requires JDK installation; works on .class files or qualified names. Cannot decompile to source code. Output depends on class accessibility and JDK version.

COMMON USE CASE

Examine bytecode: javap -cp . -c -p MyClass shows private methods disassembled.

EXIT STATUS

0 on success, 1 on error (e.g., class not found).

HISTORY

Introduced in JDK 1.0 (1996) as part of Sun Microsystems' JDK tools. Evolved with Java versions: added module support in JDK 9, --release flag in JDK 9+. Maintained in OpenJDK.

SEE ALSO

java(1), javac(1), javadoc(1), jar(1)

Copied to clipboard