Java Tools Tutorials - Herong's Tutorial Examples - v6.24, by Herong Yang
javap - Listing Public Variables and Methods
This section provides a tutorial example of how to list all public variables and methods of a class with 'javap' without any options.
In order to test the Java disassembler tool, I wrote this simple Java application file, Circle.java:
/* Circle.java
* Copyright (c) 2005 HerongYang.com. All Rights Reserved.
*/
public class Circle {
public String uom = "Centimeter";
private int x = 0;
private int y = 0;
private int r = 1;
public void setRadius(int radius) {
r = radius;
}
public void setCenter(int centerX, int centerY) {
x = centerX;
y = centerY;
}
public void printRadius() {
System.out.println(r + " " + uom);
}
public void printArea() {
double area = getArea();
System.out.println(area + " " + uom + "^2");
}
private double getArea() {
return 3.14159*r*r;
}
}
To test "javap", we need to compile this source code file into a bytecode class file, Circle.class:
herong> javac Circle.java
herong> dir Circle.*
1,393 Circle.class
610 Circle.java
Now we can see what "javap" will do for us on this bytecode class file:
herong> javap Circle
Compiled from "Circle.java"
public class Circle extends java.lang.Object{
public java.lang.String uom;
public Circle();
public void setRadius(int);
public void setCenter(int, int);
public void printRadius();
public void printArea();
}
Very nice. By default, "javap" print a list of all public variables and methods.
Table of Contents
javac - The Java Program Compiler
java - The Java Program Launcher
jpackage - Binary Package Builder
javadoc - The Java Document Generator
jdeps - The Java Class Dependency Analyzer
jdeprscan - The Java Deprecated API Scanner
jcmd - The JVM Diagnostic Tool
jconsole - Java Monitoring and Management Console
jstat - JVM Statistics Monitoring Tool
jhsdb - The Java HotSpot Debugger
jvisualvm (Java VisualVM) - JVM Visual Tool
►javap - The Java Class File Disassembler
javap - Java Disassembler Command and Options
►javap - Listing Public Variables and Methods
"javap -private" - Listing Private Variables and Methods
"javap -c -private" - Disassembling Java Bytecode Class
Looking Up Method Signature with javap Command
keytool - Public Key Certificate Tool
jrunscript - Script Code Shell
native2ascii - Native-to-ASCII Encoding Converter