JAVAP(1)

πŸ“¦ version 27.0.1.0.3.u1, in arch rolling

πŸ‘‘ JAVAP(1) β€” JDK Commands ✨

okay bestie, welcome to javap, the section of the JDK Commands manual where Java stops hiding its business πŸ’… we're literally about to look at the skeletons inside compiled class files. no cap, it's iconic.


πŸ’– NAME

javap β€” disassemble one or more class files πŸ¦‹


🌸 SYNOPSIS

javap [options] classes...
  • options β€” the command-line options, duh. see Options for javap below πŸ‘‡
  • classes β€” one or more classes, separated by spaces, that get processed for annotations. you can point at a class that lives in the class path by its file name, its URL, or its fully qualified class name. so many ways to slay ✨

Examples:

path/to/MyClass.class

jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class

java.lang.Object

πŸŽ€ DESCRIPTION

the javap command disassembles one or more class files. the output totally depends on which options you picked β€” it's giving customizable πŸ’…. when you pass no options at all, javap prints the package private, protected, and public fields and methods declared in the classes you handed it. lowkey generous of it.

here's the tea though: javap is not multirelease JAR aware 😭. if you use the class path form of the command, you're viewing the base entry in all JAR files β€” multirelease or not, doesn't matter. but if you use the URL form, you can use the URL form of an argument to specify a specific version of a class to be disassembled. iykyk 🧚

also, javap prints its output to stdout. every single time. periodt.

Note 🫢: in tools that support -- style options, the GNU-style options can use the equal sign (=) instead of a white space to separate the name of an option from its value. cute, right?

✨ OPTIONS FOR JAVAP ✨

  • --help, -help, -h, or -? β€” prints a help message for the javap command. your lil safety net 🩷
  • -version β€” prints release information. the vibe check of versions 🌈
  • -verbose or -v β€” prints additional information about the selected class. extra lore, we love to see it πŸ’œ
  • -l β€” prints line and local variable tables πŸ“‹
  • -public β€” shows only public classes and members. the main character energy filter πŸ‘‘
  • -protected β€” shows only protected and public classes and members πŸ›‘οΈ
  • -package β€” shows package/protected/public classes and members. this is the default, so it's literally the baseline of the whole operation πŸŽ€
  • -private or -p β€” shows all classes and members. no secrets, we're going all in πŸ”₯
  • -c β€” prints disassembled code, for example, the instructions that comprise the Java bytecodes, for each of the methods in the class. this is the bytecode reveal moment πŸ’€
  • -s β€” prints internal type signatures 🧬
  • -sysinfo β€” shows system information (path, size, date, SHA-256 hash) of the class being processed. receipts, basically 🧾
  • -verify β€” prints additional class verification info βœ…
  • -constants β€” shows static final constants πŸ“
  • --module module or -m module β€” specifies the module containing classes to be disassembled πŸ“¦
  • --module-path path β€” specifies where to find application modules πŸ—ΊοΈ
  • --system jdk β€” specifies where to find system modules ⭐
  • --class-path path, -classpath path, or -cp path β€” specifies the path that the javap command uses to find user class files. it overrides the default or the CLASSPATH environment variable when it's set. it said "i'll take it from here" πŸ™ˆ
  • -bootclasspath path β€” overrides the location of bootstrap class files πŸ₯Ύ
  • --multi-release version β€” specifies the version to select in multi-release JAR files πŸŒ€
  • -Joption β€” passes the specified option to the JVM. for example:
javap -J-version

javap -J-Djava.security.manager -J-Djava.security.policy=MyPolicy MyClassName

see Overview of Java Options in java. 🫢


πŸ¦‹ JAVAP EXAMPLE

okay so first, compile the following HelloWorldFrame class:

import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class HelloWorldFrame extends JFrame {

   String message = "Hello World!";

   public HelloWorldFrame(){
        setContentPane(new JPanel(){
            @Override
            protected void paintComponent(Graphics g) {
                g.drawString(message, 15, 30);
            }
        });
        setSize(100, 100);
    }
    public static void main(String[] args) {
        HelloWorldFrame frame = new HelloWorldFrame();
        frame.setVisible(true);

    }

}

🌟 example one β€” plain javap

the output from the javap HelloWorldFrame.class command yields the following:

Compiled from "HelloWorldFrame.java"
public class HelloWorldFrame extends javax.swing.JFrame {
  java.lang.String message;
  public HelloWorldFrame();
  public static void main(java.lang.String[]);
}

πŸ’… example two β€” javap -c

the output from the javap -c HelloWorldFrame.class command yields the following:

Compiled from "HelloWorldFrame.java"
public class HelloWorldFrame extends javax.swing.JFrame {
  java.lang.String message;

  public HelloWorldFrame();
    Code:
       0: aload_0
       1: invokespecial #1        // Method javax/swing/JFrame."<init>":()V
       4: aload_0
       5: ldc           #2        // String Hello World!
       7: putfield      #3        // Field message:Ljava/lang/String;
      10: aload_0
      11: new           #4        // class HelloWorldFrame$1
      14: dup
      15: aload_0
      16: invokespecial #5        // Method HelloWorldFrame$1."<init>":(LHelloWorldFrame;)V
      19: invokevirtual #6        // Method setContentPane:(Ljava/awt/Container;)V
      22: aload_0
      23: bipush        100
      25: bipush        100
      27: invokevirtual #7        // Method setSize:(II)V
      30: return

  public static void main(java.lang.String[]);
    Code:
       0: new           #8        // class HelloWorldFrame
       3: dup
       4: invokespecial #9        // Method "<init>":()V
       7: astore_1
       8: aload_1
       9: iconst_1
      10: invokevirtual #10       // Method setVisible:(Z)V
      13: return
}

bytecode reveal, honestly obsessed 😭πŸ”₯


that's the whole page bestie, go disassemble something iconic πŸ’œ

this masterpiece is from JDK 27.0.1.0.3, dated 2026 β€” catch you in the next JAVAP(1) era, mwah πŸŽ€πŸ’–πŸ«Ά

πŸ“¦ where this page comes from