Hot to use javadoc to document a package

The javadoc tool lets you generate HTML-based documentation like the documentation for Java API.

A javadoc comment starts with /** and ends with */.

Within a javadoc comment, any additional asterisks are ignored.

Because of that, asterisks are commonly used as shown here to set the comments off from the rest of code.

For these comments to work, thy must be coded directly above the class, field, constructor or method that they describe.

package com.qbw;
import java.text.NumberFormat;
/*********************************************
* the comment go here <code>HTML comment</code>
* more comments go here
* @author daq
* @version 1.0.0
* @param
* @return
**********************************************/
public class Product
{
private String code;
/******************************
* constructor comment
*******************************/
public Product()
{
}
/******************************
* method comment
*******************************/
public String getCode()
{
return this.code;
}
}

You can use HTML in javadoc comments by placing <code>asdf</code> or <b>asdf</b> in your comment.

Common javadoc tags

  • @author daq
  • @version 1.0.0
  • @param input param and descrition
  • @return description

To generate the doumentation for a package:

c:\paraentDir>javadoc -d docsDirectory packageName1 [packageName2] . . .