Using Javadoc - A Sample Class with Some Comments
(Page 3 of 5 )
We have provided a sample Java class that incorporates a number of the tags listed above. Download the sample code here and take a few minutes to examine its contents.
Creating Documentation in HTML Format
Generate the Java documentation for the sample class by executing the command in listing 2A. The first two options, “-author –version”, instruct the javadoc tool to respect the @author & @version tags. Otherwise, javadoc will ignore these tags during document creation. The last option, “-d c:documentation”, informs javadoc to generate the documents to the specified directory.
Listing 2A: Generate documentation through the Javadoc tool
javadoc –author –version –d c:documentation JavaDocDemo.java
The screen shot (Figure 1) shows the successful generation of the documentation.

Figure 1: Successful Generation of Javadoc
Listing 2B shows the general usage of the javadoc tool. Execute “javadoc –help” for more information regarding the available options.
Listing 2B: Generate documentation for the sample class.
javadoc [options] [packagenames] [sourcefiles] [classnames] [@files]
Next: Taking a Peek at the Automagically Generated Documentation >>
More Java Articles
More By Kulvir S. Bhogal