How to Write Comments in Java Code with javadoc

In Brief...

The javadoc command line utility is a convenient way to document your Java code. To learn how to write comments for use by javadoc, follow these four steps.


  1. Open your text editor and create a new file that will contain the demonstration program. Type in the following Java statements.
    Java Source for Write Comments with Javadoc
    Notice the javadoc comments start with /** and end with **/. Various annotations are supported such as @author and @param.

  2. Save your file as

  3. Open a command prompt and navigate to the folder containing your Java program. Then type in the javadoc statement followed by the Java source file name and hit Enter.
    Run Javadoc on Write Comments with Javadoc Source
    The javadoc command will create several HTML files, including WriteCommentsWithjavadoc.html. These files will be placed in the current directory.

  4. Open WriteCommentsWithjavadoc.html in your browser. Now you see the results of writing comments in your Java code with javadoc.
    HTML Page Created by Javadoc

Related Video

Author: Stephen Withrow

Stephen has over 30 years' experience in training, development, and consulting in a variety of technology areas including Java, C, C++, XML, JavaScript, AJAX, Tomcat, JBoss, Oracle, and DB2. His background includes design and implementation of business solutions on client/server, Web, and enterprise platforms. Stephen is a published writer in both technical and non-technical endeavors. Stephen received an undergraduate degree in Computer Science and Physics from Florida State University.