What is JavaDoc tool and how to use it?
Last Updated :
13 Oct, 2025
The JavaDoc tool is a built-in documentation generator in Java that creates API documentation in HTML format. It helps developers easily maintain and share structured information about classes, methods, constructors, and fields. It helps developers:
- Create structured and professional documentation for classes, methods, and fields.
- Maintain and share readable code explanations across teams or projects.

Before using the JavaDoc tool, you must include JavaDoc comments in your source code. These comments provide descriptive information about your classes, methods, constructors, and fields.
Syntax:
/**
* This is a JavaDoc comment.
*/
A typical JavaDoc comment consists of two parts:
- Description: General explanation of the code element.
- Block tags: Provide structured metadata such as @param, @return, @author, etc.
Generating JavaDoc Documentation
You can generate documentation from the command line or through an IDE.
Command Line Method: You don’t need to compile the .java file before generating JavaDoc.
Use the following command:
javadoc file_name.java
or for an entire package:
javadoc package_name
After execution, a set of HTML files will be created. Open the index.html file to view your documentation.
Generating JavaDoc in Eclipse
- Go to Project -> Generate Javadoc.
- Choose the destination folder (default is in your workspace or C drive).
- Select the project or package to document.
- Choose specific classes and visibility level (public, protected, etc.).
- Click Next (optional: specify document title and other options).
- Click Finish to generate the documentation.
Example 1:
Java
package exa;
import java.util.Scanner;
/**
*
* @author Yash
*/
public class Example{
/**
* This is a program for adding two numbers in java.
* @param args
*/
public static void main(String[] args){
/**
* This is the main method
* which is very important for
* execution for a java program.
*/
int x, y;
Scanner sc = new Scanner(System.in);
/**
* Declared two variables x and y.
* And taking input from the user
* by using Scanner class.
*
*/
x = sc.nextInt();
y = sc.nextInt();
/**
* Storing the result in variable sum
* which is of the integer type.
*/
int sum = x + y;
/**
* Using standard output stream
* for giving the output.
* @return null
*/
System.out.println("Sum is: " + sum);
}
}
Generate JavaDoc:
To generate documentation for the above package, run:
javadoc exa
This command will create a folder with HTML documentation files. Open index.html to view the API documentation in your browser.
Screenshot of javadoc:

Below is a list of commonly used tags with their descriptions and syntax:
| Tag | Description | Syntax |
|---|
| @author | Adds the author of a class. | @author name-text |
| {@code} | Displays text in code font without interpreting the text as HTML markup or nested javadoc tags. | {@code text} |
| {@docRoot} | Represents the relative path to the generated document's root directory from any generated page. | {@docRoot} |
| @deprecated | Adds a comment indicating that this API should no longer be used. | @deprecated deprecatedtext |
| @exception | Adds a Throws subheading to the generated documentation, with the classname and description text. | @exception class-name description |
| {@inheritDoc} | Inherits a comment from the nearest inheritable class or implementable interface. | Inherits a comment from the immediate surperclass. |
| {@link} | Inserts an in-line link with the visible text label that points to the documentation for the specified package, class, or member name of a referenced class. | {@link package.class#member label} |
| {@linkplain} | Identical to {@link}, except the link's label is displayed in plain text than code font. | {@linkplain package.class#member label} |
| @param | Adds a parameter with the specified parameter-name followed by the specified description to the "Parameters" section. | @param parameter-name description |
| @return | Adds a "Returns" section with the description text. | @return description |
| @see | Adds a "See Also" heading with a link or text entry that points to reference. | @see reference |
| @serial | Used in the doc comment for a default serializable field. | @serial field-description | include | exclude |
| @serialData | Documents the data written by the writeObject( ) or writeExternal( ) methods. | @serialData data-description |
| @serialField | Documents an ObjectStreamField component. | @serialField field-name field-type field-description |
| @since | Adds a "Since" heading with the specified since-text to the generated documentation. | @since release |
| @throws | The @throws and @exception tags are synonyms. | @throws class-name description |
| {@value} | When {@value} is used in the doc comment of a static field, it displays the value of that constant. | {@value package.class#field} |
| @version | Adds a "Version" subheading with the specified version-text to the generated docs when the -version option is used. | @version version-text |
Explore
Java Basics
OOP & Interfaces
Collections
Exception Handling
Java Advanced
Practice Java