How to Write Comments in Java Code with javadoc

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 of experience in training, development, and consulting in a variety of technology areas including Python, Java, C, C++, XML, JavaScript, Tomcat, JBoss, Oracle, and DB2. His background includes design and implementation of business solutions on client/server, Web, and enterprise platforms. Stephen has a degree in Computer Science and Physics from Florida State University.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.