javap(1)
π 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 thejavapcommand. 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 thejavapcommand uses to look up classes. overrides the default or theCLASSPATHenvironment 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 injre/lib/rt.jarand several other JAR files π¦-extdir dirsβ overrides the location at which installed extensions are searched for. the default location for extensions is the value ofjava.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-slowdebug 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
- Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms