What is JavaDoc tool and how to use it?
Last Updated :
01 Nov, 2023
JavaDoc tool is a document generator tool in Java programming language for generating standard documentation in HTML format. It generates API documentation. It parses the declarations ad documentation in a set of source file describing classes, methods, constructors, and fields.
Before using JavaDoc tool, you must include JavaDoc comments /**....................*/ providing information about classes, methods, and constructors, etc. For creating a good and understandable document API for any java file you must write better comments for every class, method, constructor.

The JavaDoc comments is different from the normal comments because of the extra asterisk at the beginning of the comment. It may contain the HTML tags as well.
// Single-Line Comment/*
* Multiple-Line comment
*//**
* JavaDoc comment
*/
By writing a number of comments, it does not affect the performance of the Java program as all the comments are removed at compile time.
JavaDoc Format: -
It has two parts: - a description which is followed by block tags.
Some Integrated Development Environments (IDE) automatically generate the JavaDoc file like NetBeans, IntelliJ IDEA, Eclipse, etc.
Generation of JavaDoc: -
To create a JavaDoc you do not need to compile the java file. To create the Java documentation API, you need to write Javadoc followed by file name.
javadoc file_name or javadoc package_name
After successful execution of the above command, a number of HTML files will be created, open the file named index to see all the information about classes.
JavaDoc Tags
|
@author | author_name | Describes an author |
@param | description | provide information about method parameter or the input it takes |
@see | reference | generate a link to other element of the document |
@version | version-name | provide version of the class, interface or enum. |
@return | description | provide the return value |
To generate JavaDoc in Eclipse: -
- Select "Generate JavaDoc" option from Project menu and a wizard will appear.
- Specify the location for the JavaDoc file on your computer, by default it will be in the C drive.
- Select the project and then the packages for which you want to create the JavaDoc file.
- After this on the right side, select the classes for which you want to generate the JavaDoc, by default all the classes will be selected.
- Then you can also specify for which classes the JavaDoc will be generated by selecting the visibility.
- Select the destination location where the generated JavaDoc will be placed.
- Then click Next or Finish.
If you select Next in the next window you can select the Document title and other basic options.
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);
}
}
Generating document for the above class
javadoc exa
Screenshot of javadoc: -
Similar Reads
How to create a user defined javap tool? What is a javap tool? The javap tool is used to get the information of any class or interface. The javap command (also known as the Java Disassembler) disassembles one or more class files. Its output depends on the options used ("-c" or "-verbose" for byte code and byte code along with innards info,
4 min read
How to Use AsciiDoctor with Maven Project in Java? AsciiDoc is nothing but a text document mainly used to prepare help documents, and documentation on various concepts like documenting web pages, product review pages, etc. AsciiDoc documents can be converted into formats like PDF or HTML or EPUB etc., AsciiDoctor It is a text processor involved in c
3 min read
What is Document Object in Java DOM? Document Object Model is a commendation of the World Wide Web Consortium. It explains an interface that enables programs to access and modify the style, structure, and contents of XML documents. XML parsers that support DOM implement this interface. It can be clearly perceived from the image provide
2 min read
How to Convert a Document to PDF in Java? In software projects, there is quite often a requirement for conversion of a given file (HTML/TXT/etc.,) to a PDF file and similarly, any PDF file needs to get converted to HTML/TXT/etc., files. Even PDFs need to be stored as images of type PNG or GIF etc., Via a sample maven project, let us see the
6 min read
What are Office Tools? Office Tools include some Application Software that are used to create, update, manage documents, handle large data, create presentations etc. These tools if used effectively, can save a large amount of time and effort. Lots of repetitive tasks can be done very easily. In this article, we will discu
3 min read