21. The Java Development Kit

21.2. The Java Documentation Tool: 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 follow- ing 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 Sun’s Web site. To illustrate how it might be used, let’s just look at a simple example.

The FirstApplet program from Chapter 1 contains documentation com- ments. It was processed using the following command:

,,

 

J

javadoc generated the following HTML documents:

,,

 

 

 

 

 

 

 

J

 

To see how the documentation appears, review the FirstApplet.java source file and the documentation it generated. Both are available at

,,

 

J

 

 

 

 

 

 

 

Appendix C