HelloDocumented.java - javadoc-Style Comments

This section provides a tutorial example of how to add javadoc-style comments in Java class source code.

If you want to use "javadoc" command to generate an API document for your Java class, you should provide a comment before the class declaration statement and each class member declaration statement using the following syntax:

/**
 * class_method_property_description
 * @tag_name [argument] tag_description
 * @tag_name [argument] tag_description
 * @...
 */

where:

Below is a new version my Hello class with javadoc-style comments added.

/**
 * A simple class to demonstrate 'javadoc' comment features.
 * @author Herong Yang
 */
public class HelloDocumented {

  /**
   * Name of the guest.
   */
  public static String guest = "Herong";

  /**
   * The entry point to execute this class.
   * @param a Array of arguments
   */
  public static void main(String[] a) {
    System.out.println("Hello "+guest+"!");
  }
}

Let's see what will be generated by "javadoc" command.

herong$ javadoc HelloDocumented.java

Loading source file HelloDocumented.java...
Constructing Javadoc information...
Standard Doclet version 15+36-1562
Building tree for all the packages and classes...
Generating ./HelloDocumented.html...
Generating ./package-summary.html...
Generating ./package-tree.html...
Generating ./constant-values.html...
Generating ./overview-tree.html...
Generating ./deprecated-list.html...
Building index for all the packages and classes...
Generating ./index-all.html...
Building index for all classes...
Generating ./allclasses-index.html...
Generating ./allpackages-index.html...
Generating ./index.html...
Generating ./help-doc.html...

Open "index.html" in a Web browser, you should see the API document with addition information extracted from those comments in the Java source file.

API Document Generated from javadoc-Style Comments
API Document Generated from javadoc-Style Comments

For more information on "javadoc" tags and usage examples, see "javadoc - The Java API Documentation Generator" at https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 java - The Java Program Launcher

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

javadoc - The Java Document Generator

 javadoc - Document Generator Command and Options

 Hello.java API Document

HelloDocumented.java - javadoc-Style Comments

 Generate API Document for Java Package

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jhsdb - The Java HotSpot Debugger

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials

 References

 Full Version in PDF/EPUB