Javadocs
Javadoc is a tool that generates Java code documentation in the HTML format from Java source code. The documentation is formed from Javadoc comments that are usually placed above classes, methods, or fields. For more information on the correct format of Javadocs, style guide, terms and conventions, refer to How to Write Doc Comments for the Javadoc Tool.
tip
Documentation comments are also available in JavaScript, Python, Ruby, PHP, and Kotlin.
Add a new comment
Add a Javadoc using automatic comments
For documentation comments, IntelliJ IDEA provides completion that is enabled by default.
Type
/**
before a declaration and press Enter. The IDE auto-completes the doc comment for you.Gif
For information on how to disable this feature, refer to Disable automatic comments.
Add a Javadoc using context actions
Place the caret at the declaration in the editor, press Alt+Enter, and select Add Javadoc from the list.
note
For method comments, the new comment stub contains the required tags (
@param
tags for each method parameter,@return
, or@throws
).
In Kotlin, the @param
and other tags are not generated because the recommended style requires incorporating the description of parameters and return values directly into the documentation comment.
tip
For information on how to document Kotlin code, refer to Kotlin documentation.
Disable automatic comments
In the Settings/Preferences dialog Ctrl+Alt+S, go to Editor | General | Smart Keys, and clear the Insert documentation comment stub checkbox.
Fix a Javadoc
If a method signature has been changed, IntelliJ IDEA highlights the tag that doesn't match the method signature and suggests a quick-fix. Press Alt+Enter to apply the fix.
You can also update an existing javadoc comment in order to account for the changes in the declaration using the Fix doc comment action:
Place the caret within a class, method, function, or a field, and press Ctrl+Shift+A.
Type
fix doc comment
and press Enter.
tip
You can use the Fix doc comment action to add missing documentation stub with the corresponding tags: place the caret within a class, method, or function and invoke the action.
Render Javadocs
IntelliJ IDEA allows you to render Javadocs in the editor. Rendered comments are easier to read, and they don't overload your code with extra tags.
Click in the gutter next to the necessary documentation comment (or press Ctrl+Alt+Q) to toggle the rendered view; click
to edit the comment.

Rendered Javadocs allow you to click links to go to the referenced web pages, or view quick documentation for the referenced topics.
To change the font size, right-click a Javadoc in the editor and select Adjust Font Size from the context menu. Note that the rendered comments use the same font size as the quick documentation popup.
Render Javadocs by default
You can configure the IDE to always render Javadocs in the editor.
Right-click the icon in the gutter (
or
) and enable the Render All option.
Alternatively, in the Settings/Preferences dialog Ctrl+Alt+S, select Editor | General | Appearance and enable the Render documentation comments option.
To edit rendered Javadocs, click the icon in the gutter next to the comment.
Generate a Javadoc reference
IntelliJ IDEA provides a utility that enables you to generate a Javadoc reference for your project.
From the main menu, select Tools | Generate JavaDoc.
In the dialog that opens, select a scope — a set of files or directories for which you want to generate the reference, and set the output directory where the generated documentation will be placed.
The Output directory is a mandatory field: you cannot generate a Javadoc file as long it is empty.
Use the slider to define the visibility level of members that will be included in the generated documentation. Select one of the following options:
Private: to include all classes and members to the reference.
Package: to include all classes and members except the private ones.
Protected: to include public and protected classes and members.
Public: to include only public classes and members.
You can specify a locale (for example
en_US.UTF-8
), command line arguments, and the maximum heap size.Click OK to generate the reference.

View Javadocs in the editor
In IntelliJ IDEA, you can view Javadocs for any symbol or method signature right from the editor. To be able to do that, configure library documentation paths or add downloaded Javadocs to the IDE. For more information, refer to Configure library documentation.
Hover the mouse over the necessary symbol to view its documentation, or place the caret at the symbol, and press Ctrl+Q (View | Quick Documentation ).
Press Ctrl+Q again to switch between the popup and the toolbar.
Click in the popup to change the font size, display the quick documentation toolbar, or go to the source code.
For more information, refer to Quick documentation
Troubleshoot
javadoc: error - Malformed locale name: en_US.UTF-8
Clear the Locale field. In the Other command line arguments field, add -encoding utf8 -docencoding utf8 -charset utf8
.
-encoding
specifies the encoding of the source files. -docencoding
specifies the encoding of the output HTML files and -charset
is the charset specified in the HTML head section of the output files.