Sharing is caring!

Creating Javadoc with NetBeans

Creating Javadoc with NetBeans

This tutorial will guide you on the steps needed for Creating Javadoc with NetBeans IDE. The first approach will discuss Mounting and accessing an already existing Javadoc, while the second will discuss Generating Javadoc, lastly, we will focus on using the Auto-commenting tool that helps you add Javadoc comments to your own source file.

NetBeans supports the Javadoc standard for Java documentation (both viewing it and generating it). It gives the Programmer a solid documentation tool when working with code.

Mounting and accessing Javadoc
You may have noticed the Javadoc tab in the Explorer window. This operates much like the Filesystems tab where you mount source files, except here you mount directories containing Javadoc documentation. An empty directory is mounted there by default – this is where the IDE puts Javadoc documentation you generate for your own code (see below for details on generating Javadoc).

You can also mount existing Javadoc documentation here (for example, the JDK documentation, or the Javadoc for the Open APIs for NetBeans). Any documentation you mount here is included when you do a search. For example, if you have the JDK Javadoc mounted and you press CTRL-F1 while the insertion point in the Editor is over the words javax.swing.JButton, the documentation for JButton pops up almost instantly. You can search all mounted documentation by choosing Help | Javadoc Index Search.

Generating Javadoc
Javadoc documentation can be generated from specially formatted comments within source files (the comments should start with /** and end with */). If your source code contains these comments, you can generate Javadoc documentation by right-clicking on the class or package in the Explorer and choosing Tools, click ‘Generate Javadoc’ from the context menu. The documentation will be generated in the default directory mounted in the Javadoc tab of the Explorer.


Fig 1: Screenshot showing how to generate Javadoc (Click to enlarge)

Entering Javadoc comments in source files – the Auto Comment tool
You can easily add Javadoc comments to your own source files using a tool within the IDE. Right-click your class file and choose Tools | Auto Comment. A dialog pops up and allows you to run through all the members of your class and enter comments, which are added to the source file. It even verifies that there are no parameters you have not accounted for, so you can be sure that your comments are complete.


Fig 2: Screenshot showing how to use the Tool | Auto Comment (Click to enlarge)

If a member is marked by an X, or you want to edit the comment for that item, click either the Edit Comment or the AutoCorrect button to open the comment editor for that item. AutoCorrect will fill in fields in the comment to define variables passed to a method so that the comment completely documents the method signature.

Sharing is caring!

Creating Javadoc with NetBeans
Article Name
Creating Javadoc with NetBeans
This tutorial will guide you on the steps needed for Creating Javadoc with NetBeans IDE. The first approach will discuss Mounting and .......
Publisher Name
Publisher Logo