Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.10

Listing Private Variables and Methods with 'javap -private'

This section provides a tutorial example of how to list all private and public variables and methods of a class with 'javap' with the '-private' option.

From the previous tutorial, we learned that the default behavior of the "javap" command is to list all public variables and methods of the specified class.

If you want to list both public and private variables and methods, you can use the "javap" command with the "-private" option:

C:\herong>javap -private Circle

Compiled from "Circle.java"
public class Circle extends java.lang.Object{
    public java.lang.String uom;
    private int x;
    private int y;
    private int r;
    public Circle();
    public void setRadius(int);
    public void setCenter(int, int);
    public void printRadius();
    public void printArea();
    private double getArea();
}

As you can see from the output, all private and public variables and methods are printed by the "javap" command.

Sections in This Chapter

'javap' - Java Disassembler Command and Options

Listing Public Variables and Methods with 'javap'

Listing Private Variables and Methods with 'javap -private'

Disassembling Java Bytecode Class Files with 'javap -c -private'

Looking Up Method Signature with 'javap' Command

Dr. Herong Yang, updated in 2008
Listing Private Variables and Methods with 'javap -private'