Main Content

Looking inside Java classes - javap and javadoc

Archive - Originally posted on "The Horse's Mouth" - 2009-09-25 16:09:23 - Graham Ellis

javap is a program that looks inside a Java class and reports on all the methods and variables that are exposed by that class ... so it's looking at a Java class's object format.

javadoc is a program that analyses Java source code and reports on all the methods that are exposed by that class.

javap is command line based, but javadoc produces a whole web site in HTML format ... here's the javap output from our "Time" class from this week:

Dorothy-2:java grahamellis$ javap Time
Compiled from "Time.java"
public class Time extends java.lang.Object{
  public int hour;
  public int minute;
  public int second;
  public static int howmany;
  public Time(int, int, int);
  public Time(int, int);
  public int getsid();
  public int gethour();
  public void setforward(int);
  public java.lang.String getdef();
  public int getgap(Time);
  public static int getcount();
  static {};
}


And here's part of the javadoc output from the same class:

Explore the full javadoc tree from this week if you wish. It's in HTML, using frames (so I can't easily provide you with a link to the intermediate pages without doctoring files and URLs!) but it WILL take you all the way from Adam to Zoe!