Adding a Javadoc Comment to Source Code

You can type a Javadoc comment directly in the Source Editor. If you need help with the content or format of the comment, use the Javadoc Comment dialog box to create your comment.

To add a comment using the Source Editor:

  1. Place the insertion point in the line immediately before the class, interface, constructor, method, or field declaration you want to document.

  2. Type your comment.

    A Javadoc comment begins with the characters /**, ends with the characters */ and includes a description followed by Javadoc tags.

  3. Save your changes in the Source Editor.

To add a comment using the Javadoc Comment dialog box:

  1. In the Filesystems tab of the Explorer, right-click the source file for which you want to create documentation.

  2. From the contextual menu, choose Tools Auto Comment.

    The Auto Comment Tool dialog box lists the classes, interfaces, and other entities in the source code and their Javadoc status ( indicates a valid Javadoc comment, indicates a partial or erroneous comment, and indicates no comment).

  3. In the Auto Comment Tool dialog box, select the entity you want to comment.

  4. Type the description in the Javadoc Comment Text field.

    The first sentence of the comment should be a summary description of the declared entity. At the bottom of the dialog box is a row of command buttons you can use to include HTML elements (<B>, <I>, <U>, <CODE>, <PRE>) for formatting your text and the Javadoc tag {@link}.

  5. Include the desired Javadoc tags:
    a. Click New.

    b. In the New Tag dialog box, select a Javadoc tag or type a new tag and click OK.

    c. In the Description field, type the text of the tag, including HTML formatting elements (such as <B> and <I>) and the in-line Javadoc tag {@link}.

    The Javadoc comment is added to the source code immediately above the declaration. The comment begins with the characters /** and ends with the characters */.

  6. Open the Source Editor and save your changes.
To open multiple source files for comment, hold down the Shift key, select the file names, right-click, and choose Tools Auto Comment.
For more information about Javadoc tags, visit the Sun Microsystems web page at
http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/javadoc.html. For information on how to write Javadoc comments, see
http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html.
See also
Javadoc Comments
Generating Documentation With Javadoc
Customizing the Output of Javadoc

Legal Notices