Skip to main content

Section B.4 The Java Documenter: javadoc

The javadoc tool parses the declarations and documentation comments in a Java source file and generates a set of HTML pages that describes the following elements: public and protected classes, inner classes, interfaces, constructors, methods, and fields.

The javadoc tool can be used on a single file or an entire package of files. Recall that a Java documentation comment is one that begins with /** and ends with */. These are the comments that are parsed by javadoc.

The javadoc tool has many features, and it is possible to use Java doclets to customize your documentation. For full details on using the tool, it is best to consult Oracle's javadoc Web site. To illustrate how it might be used, let's look at a simple example.

 * A simple hello program
 * @author Java Java Java
 * @version 1.0
public class Hello {

     * Prints a simple greeting.
     * @param None
     * @return void
    public void sayHello() {

    public static void main(String args[]) {
        Hello hello = new Hello();

The Hello program contains documentation comments. To process it we would use the following command:


javadoc would generate the following HTML documents:

Hello.html            -The main documentation file
allclasses-frame.html -Names and links to all the classes used in
overview-tree.html    -A tree showing Hello's place
                       in the class hierarchy
packages.html         -Details on the packages used in Hello
index.html            -Top-level HTML document for
                       Hello documentation
index-all.html        -Summary of all methods and variables in

To see how everything looks, check out the online Hello documentation.

You have attempted of activities on this page.