javap(1)

πŸ“¦ version 11.0.20.1.1, in centos-stream 9

πŸ’… javap(1) β€” Basic Tools, bestie edition

okay so quick vibe check: this whole page lives in the Basic Tools section of the manual, and it's all about javap. Buckle up, we're going in 🫢

✨ NAME ✨

javap β€” disassembles one or more class files. That's it, that's the whole gig. πŸ’…

✨ SYNOPSIS ✨

javap [options] classfile...

options πŸŽ€

the command-line options, duh. go look at OPTIONS below, i got you ✨

classfile πŸŽ€

one or more classes, separated by spaces, that get processed for annotations like DocFooter.class. and like β€” you're not stuck with one format, bestie. you can specify a class that can be found in the class path, or by its file name, or even with a URL like file:///home/user/myproject/src/DocFooter.class. versatile queen πŸ‘‘

✨ DESCRIPTION ✨

so the javap command disassembles one or more class files. the output depends on which options you used β€” different options, different lore 🌈

when you use no options at all, javap prints the package, protected and public fields, and methods of the classes you passed in. and it prints its output to stdout, obviously πŸ’–

✨ OPTIONS ✨

okay this is the part everyone actually came for, let's go πŸ”₯

  • -help, --help, -? β€” prints a help message for the javap command. three whole ways to ask for help, pick your fighter 🫢
  • -version β€” prints release information. which era of Java are we in, iykyk ⭐
  • -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 🌸
  • -private, -p β€” shows all classes and members. no secrets, we're going feral, nothing is hidden πŸ’€
  • -Joption β€” passes the specified option to the JVM. for example:
javap -J-version
javap -J-Djava.security.manager -J-Djava.security.policy=MyPolicy MyClassName

for more information about JVM options, see the command documentation πŸ“š

  • -s β€” prints internal type signatures 🧚
  • -sysinfo β€” shows system information (path, size, date, MD5 hash) of the class being processed. the whole receipts, literally 🧾
  • -constants β€” shows static final constants πŸ’œ
  • -c β€” prints disassembled code β€” like, the actual instructions that comprise the Java bytecodes, for each of the methods in the class. this is the good stuff, no cap πŸ”₯
  • -verbose β€” prints stack size, number of locals and arguments for methods. yes she tells you everything πŸ™ˆ
  • -classpath path β€” specifies the path the javap command uses to look up classes. overrides the default or the CLASSPATH environment variable when it is set πŸ’…
  • -bootclasspath path β€” specifies the path from which to load bootstrap classes. by default, the bootstrap classes are the classes that implement the core Java platform located in jre/lib/rt.jar and several other JAR files πŸ“¦
  • -extdir dirs β€” overrides the location at which installed extensions are searched for. the default location for extensions is the value of java.ext.dirs πŸ¦‹

✨ EXAMPLE ✨

ok so first compile the following DocFooter class πŸ‘‡

import java.awt.*;
import java.applet.*;

public class DocFooter extends Applet {
        String date;
        String email;

        public void init() {
                resize(500,100);
                date = getParameter("LAST_UPDATED");
                email = getParameter("EMAIL");
        }

        public void paint(Graphics g) {
                g.drawString(date + " by ",100, 15);
                g.drawString(email,290,15);
        }
}

the output from the javap DocFooter.class command yields the following ✨

Compiled from "DocFooter.java"
public class DocFooter extends java.applet.Applet {
  java.lang.String date;
  java.lang.String email;
  public DocFooter();
  public void init();
  public void paint(java.awt.Graphics);
}

and the output from the javap -c DocFooter.class command yields the following β€” yes this is the spicy one πŸ”₯

Compiled from "DocFooter.java"
public class DocFooter extends java.applet.Applet {
  java.lang.String date;
  java.lang.String email;

  public DocFooter();
    Code:
       0: aload_0
       1: invokespecial #1                  // Method
java/applet/Applet."<init>":()V
       4: return

  public void init();
    Code:
       0: aload_0
       1: sipush        500
       4: bipush        100
       6: invokevirtual #2                  // Method resize:(II)V
       9: aload_0
      10: aload_0
      11: ldc           #3                  // String LAST_UPDATED
      13: invokevirtual #4                  // Method
 getParameter:(Ljava/lang/String;)Ljava/lang/String;
      16: putfield      #5                  // Field date:Ljava/lang/String;
      19: aload_0
      20: aload_0
      21: ldc           #6                  // String EMAIL
      23: invokevirtual #4                  // Method
 getParameter:(Ljava/lang/String;)Ljava/lang/String;
      26: putfield      #7                  // Field email:Ljava/lang/String;
      29: return

  public void paint(java.awt.Graphics);
    Code:
       0: aload_1
       1: new           #8                  // class java/lang/StringBuilder
       4: dup
       5: invokespecial #9                  // Method
 java/lang/StringBuilder."<init>":()V
       8: aload_0
       9: getfield      #5                  // Field date:Ljava/lang/String;
      12: invokevirtual #10                 // Method
 java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      15: ldc           #11                 // String  by
      17: invokevirtual #10                 // Method
 java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      20: invokevirtual #12                 // Method
 java/lang/StringBuilder.toString:()Ljava/lang/String;
      23: bipush        100
      25: bipush        15
      27: invokevirtual #13                 // Method
 java/awt/Graphics.drawString:(Ljava/lang/String;II)V
      30: aload_1
      31: aload_0
      32: getfield      #7                  // Field email:Ljava/lang/String;
      35: sipush        290
      38: bipush        15
      40: invokevirtual #13                 // Method
java/awt/Graphics.drawString:(Ljava/lang/String;II)V
      43: return
}

✨ SEE ALSO ✨

the friend group 🫢 go check them out:


and that's the whole page, bestie 🌸 this was the JDK 8 era of things, dated 8 August 2014 β€” vintage but still iconic, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from
  • centos-stream 9: java-11-openjdk-devel 1:11.0.20.1.1-2.el9 Β· ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib and ISC and FTL and RSA
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms