JAVADOC(1)
π javadoc β JDK Commands π
okay so this is the JAVADOC(1) manual page, and itβs literally the glow-up guide for javadoc, the JDK tool that makes API docs out of Java source files. bestie, itβs giving βturn your comments into HTMLβ energy, and weβre gonna go through every single detail. no skipping. periodt. β¨
πΈ NAME πΈ
javadoc β generate HTML pages of API documentation from Java source files. π«Ά
π¦ SYNOPSIS π¦
javadoc [options] [packagenames] [sourcefiles] [@files]
optionsβ command-line options, separated by spaces. See Standard javadoc Options, Extra javadoc Options, Standard Options for the Standard Doclet, and Extra Options for the Standard Doclet. πpackagenamesβ names of packages you want to document, separated by spaces, for examplejava.lang java.lang.reflect java.awt. If you also wanna document the subpackages, use the-subpackagesoption to specify the packages.
By default, javadoc looks for the specified packages in the current directory and subdirectories. Use the -sourcepath option to specify the list of directories where to look for packages. π
sourcefilesβ names of Java source files you want to document, separated by spaces, for exampleClass.java Object.java Button.java. By default,javadoclooks for the specified classes in the current directory. However, you can specify the full path to the class file and use wildcard characters, for example/home/src/java/awt/Graphics*.java. You can also specify the path relative to the current directory. π¦@filesβ names of files that contain a list ofjavadoctool options, package names, and source file names in any order. π
π DESCRIPTION π
The javadoc tool parses the declarations and documentation comments in a set of Java source files and produces corresponding HTML pages that describe (by default) the public and protected classes, nested and unnamed classes (but not anonymous inner classes), interfaces, constructors, methods, and fields. You can use the javadoc tool to generate the API documentation or the implementation documentation for a set of source files. π
You can run the javadoc tool on entire packages, individual source files, or both. When documenting entire packages, you can use the -subpackages option either to recursively traverse a directory and its subdirectories, or to pass in an explicit list of package names. When you document individual source files, pass in a list of Java source file names. π
π Conformance π
The Standard Doclet does not validate the content of documentation comments for conformance, nor does it attempt to correct any errors in documentation comments. Anyone running javadoc is advised to be aware of the problems that may arise when generating non-conformant output or output containing executable content, such as JavaScript. The Standard Doclet does provide the DocLint feature to help developers detect common problems in documentation comments; but it is also recommended to check the generated output with any appropriate conformance and other checking tools. π
For more details on the conformance requirements for HTML5 documents, see Conformance requirements in the HTML5 Specification: https://www.w3.org/TR/html5/infrastructure.html#conformance-requirements. For more details on security issues related to web pages, see the Open Web Application Security Project (OWASP) page: https://www.owasp.org. π«Ά
π₯ OPTIONS π₯
javadoc supports command-line options for both the main javadoc tool and the currently selected doclet. The Standard Doclet is used if no other doclet is specified. β¨
GNU-style options (that is, those beginning with --) can use an equal sign (=) instead of whitespace characters to separate the name of an option from its value. π
β Standard javadoc Options β
The following core javadoc options are equivalent to corresponding javac options. See Standard Options in javac for the detailed descriptions of using these options: π
--add-modules-bootclasspath--class-path,-classpath, or-cp--enable-preview-encoding-extdirs--limit-modules--module--module-pathor-p--module-source-path--release--sourceor-source--source-pathor-sourcepath--system--upgrade-module-path
The following options are the core javadoc options that are not equivalent to a corresponding javac option: π¦
-breakiteratorβ computes the first sentence withBreakIterator. The first sentence is copied to the package, class, or member summary and to the alphabetic index. TheBreakIteratorclass is used to determine the end of a sentence for all languages except for English.- English default sentence-break algorithm --- Stops at a period followed by a space or an HTML block tag, such as
<P>. - Breakiterator sentence-break algorithm --- Stops at a period, question mark, or exclamation point followed by a space when the next word starts with a capital letter. This is meant to handle most abbreviations (such as "The serial no. is valid", but will not handle "Mr. Smith"). The
-breakiteratoroption doesn't stop at HTML tags or sentences that begin with numbers or symbols. The algorithm stops at the last period in../filename, even when embedded in an HTML tag. π
- English default sentence-break algorithm --- Stops at a period followed by a space or an HTML block tag, such as
-docletclass β generates output by using an alternate doclet. Use the fully qualified name. This doclet defines the content and formats the output. If the-docletoption isn't used, then thejavadoctool uses the standard doclet for generating the default HTML format. This class must contain thestart(Root)method. The path to this starting class is defined by the-docletpathoption. π-docletpathpath β specifies where to find doclet class files (specified with the-docletoption) and any JAR files it depends on. If the starting class file is in a JAR file, then this option specifies the path to that JAR file. You can specify an absolute path or a path relative to the current directory. Ifclasspathlistcontains multiple paths or JAR files, then they should be separated with a colon (:) on Linux and a semi-colon (;) on Windows. This option isn't necessary when the doclet starting class is already in the search path. π-excludepkglist β unconditionally excludes the specified packages and their subpackages from the list formed by-subpackages. It excludes those packages even when they would otherwise be included by some earlier or later-subpackagesoption.
The following example would include java.io, java.util, and java.math (among others), but would exclude packages rooted at java.net and java.lang. Notice that these examples exclude java.lang.ref, which is a subpackage of java.lang. π
- Linux and macOS:
javadoc -sourcepath /home/user/src -subpackages java -exclude java.net:java.lang
- Windows:
javadoc -sourcepath \user\src -subpackages java -exclude java.net:java.lang
--expand-requiresvalue β instructs thejavadoctool to expand the set of modules to be documented. By default, only the modules given explicitly on the command line are documented. Supports the following values:transitive: additionally includes all the required transitive dependencies of those modules.all: includes all dependencies. π¦
--help,-help,-h, or-?β prints a synopsis of the standard options. π--help-extraor-Xβ prints a synopsis of the set of extra options. β¨-Jflagβ passesflagdirectly to the Java Runtime Environment (JRE) that runs thejavadoctool. For example, if you must ensure that the system sets aside 32 MB of memory in which to process the generated documentation, then you would call the-Xmxoption as follows:javadoc -J-Xmx32m -J-Xms32m com.mypackage. Be aware that-Xmsis optional because it only sets the size of initial memory, which is useful when you know the minimum amount of memory required.
There is no space between the J and the flag. β οΈ
Use the -version option to report the version of the JRE being used to run the javadoc tool.
javadoc -J-version
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
-localename β specifies the locale that thejavadoctool uses when it generates documentation. The argument is the name of the locale, as described injava.util.Localedocumentation, such asen_US(English, United States) oren_US_WIN(Windows variant). π
Specifying a locale causes the javadoc tool to choose the resource files of that locale for messages such as strings in the navigation bar, headings for lists and tables, help file contents, comments in the stylesheet.css file, and so on. It also specifies the sorting order for lists sorted alphabetically, and the sentence separator to determine the end of the first sentence. The -locale option doesn't determine the locale of the documentation comment text specified in the source files of the documented classes. π
-packageβ shows only package, protected, and public classes and members. π-privateβ shows all classes and members. π-protectedβ shows only protected and public classes and members. This is the default. π-publicβ shows only the public classes and members. πΈ-quietβ shuts off messages so that only the warnings and errors appear to make them easier to view. It also suppresses the version string. π€«--show-membersvalue β specifies which members (fields or methods) are documented, wherevaluecan be any of the following:public--- shows only public membersprotected--- shows public and protected members; this is the defaultpackage--- shows public, protected, and package membersprivate--- shows all members π
--show-module-contentsvalue β specifies the documentation granularity of module declarations, wherevaluecan beapiorall. π¦--show-packagesvalue β specifies which modules packages are documented, wherevaluecan beexportedorall packages. π--show-types valueβ tells the tool which types (classes, interfaces, whatever) get actual documentation written for them.valuecan be literally any of these:publicβ only public types get shown πprotectedβ public and protected types get shown; this is the default, bestie, it's what you get if you don't say anythingpackageβ public, protected, and package typesprivateβ literally everything gets shown, no secrets, zero privacy, main character energy π
-subpackages subpkglistβ generates docs from source files in the packages you name and recursively in all their subpackages. This one's lowkey iconic when you're adding new subpackages to your source, because they get swept up automatically, no extra work from you π«Ά. Each package argument is any top-level subpackage (likejava) or fully qualified package (likejavax.swing) β and ngl it doesn't even need to contain source files. Arguments are separated by colons on all operating systems. Wildcards are not allowed, periodt. Use-sourcepathto tell it where to find the packages. Heads up though: this option does not process source files that live in the source tree but don't belong to the packages.
For example, the following commands generate documentation for packages named java and javax.swing and all of their subpackages:
- Linux and macOS:
javadoc -d docs -sourcepath /home/user/src -subpackages java:javax.swing
- Windows:
javadoc -d docs -sourcepath \user\src -subpackages java:javax.swing
-verboseβ gives you more detailed messages while thejavadoctool runs. Without it, you get messages for loading the source files, generating the documentation (one message per source file), and sorting. With-verboseyou get extra messages that specify the number of milliseconds it took to parse each Java source file. Very "tell me everything" of it β¨--versionβ prints version information. That's it. That's the whole thing π-Werrorβ reports an error if any warnings occur. Like, any warning at all. Zero tolerance, we love a strict queen π
π§ͺ Extra javadoc Options
Note: the additional options for javadoc are subject to change without notice. Fr fr, don't get too attached π
The following extra javadoc options are equivalent to the corresponding javac options. See Extra Options in javac for the detailed descriptions of how to use these:
--add-exports--add-reads--patch-module-Xmaxerrs-Xmaxwarns
π Standard Options for the Standard Doclet
These are the options the standard doclet itself provides, bestie. Yes, there's a whole separate crew of them:
--add-script fileβ addsfileas an extra JavaScript file into the generated documentation. You can use this option one or more times to specify additional script files. Obsessed with a repeatable flag πΈ
Command-line example:
javadoc --add-script first_script.js --add-script second_script.js pkg_foo
--add-stylesheet fileβ addsfileas an extra stylesheet file into the generated documentation. Just like the scripts, you can use this option one or more times to specify additional stylesheets included in the documentation π
Command-line example:
javadoc --add-stylesheet new_stylesheet_1.css --add-stylesheet new_stylesheet_2.css pkg_foo
--allow-script-in-commentsβ allows JavaScript in options and comments. That's the whole vibe check π¦-authorβ includes the@authortext in the generated docs. Credit where credit is due, periodt π-bottom html-codeβ sets the text placed at the bottom of each output file. It goes at the bottom of the page, underneath the lower navigation bar. The text can contain HTML tags and white space, but when it does, you must wrap the text in quotation marks. Use escape characters for any internal quotation marks within the text.-charset nameβ sets the HTML character set for this document.nameshould be a preferred MIME name as specified in the IANA Registry, Character Sets [http://www.iana.org/assignments/character-sets].
For example:
javadoc -charset "iso-8859-1" mypackage
This command inserts the following line in the head of every generated page:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
The meta tag is described in the HTML standard (4197265 and 4137321), HTML Document Representation [http://www.w3.org/TR/REC-html40/charset.html#h-5.2.2].
-d directoryβ sets the destination directory where thejavadoctool saves the generated HTML files. If you omit-d, the files go to the current directory. Thedirectoryvalue can be absolute or relative to the current working directory. And don't stress β the destination directory is automatically created when thejavadoctool runs π«Ά- Linux and macOS: for example, the following command generates the documentation for the package
com.mypackageand saves the results in the/user/doc/directory:
- Linux and macOS: for example, the following command generates the documentation for the package
javadoc -d /user/doc/ com.mypackage
- Windows: for example, the following command generates the documentation for the package
com.mypackageand saves the results in the\user\doc\directory:
javadoc -d \user\doc\ com.mypackage
-docencoding nameβ sets the encoding of the generated HTML files.nameshould be a preferred MIME name as specified in the IANA Registry, Character Sets [http://www.iana.org/assignments/character-sets].
There are three options available for use in a javadoc encoding command. The -encoding option is used for encoding the files read by the javadoc tool, while -docencoding and -charset are used for encoding the files written by the tool. Of the three available options, at most only the input and one output encoding option are used in a single encoding command. If you specify both an input and an output encoding option in a command, they must be the same value. If you specify neither output option, it defaults to the input encoding. Lowkey a whole encoding saga π
For example:
javadoc -docencoding "iso-8859-1" mypackage
-docfilessubdirsβ recursively copies doc-file subdirectories. Enables deep copying ofdoc-filesdirectories. Subdirectories and all contents get recursively copied to the destination. For example, the directorydoc-files/example/imagesand all of its contents are copied. You can use the-excludedocfilessubdiroption to exclude specific subdirectories π-doctitle html-codeβ sets the title to place near the top of the overview summary file. The text specified in the title tag gets placed as a centered, level-one heading directly beneath the top navigation bar. The title tag can contain HTML tags and white space, but when it does, you must enclose the title in quotation marks. Additional quotation marks within the title tag must be escaped. For example,javadoc -doctitle "<b>My Library</b><br>v1.0" com.mypackage.-excludedocfilessubdir name1,name2...β excludes any subdirectories with the given names when recursively copying doc-file subdirectories. See-docfilessubdirs. And for historical reasons,:can be used anywhere in the argument as a separator instead of,. History is weird, we respect it π§-footer html-codeβ sets the footer text placed at the bottom of each output file. Thehtml-codevalue goes to the right of the lower navigation bar. Thehtml-codevalue can contain HTML tags and white space, but when it does, thehtml-codevalue must be enclosed in quotation marks. Use escape characters for any internal quotation marks within a footer.-group name p1,p2...β groups the specified packages together on the Overview page. For historical reasons,:can be used as a separator anywhere in the argument instead of,. Cute lil grouping moment π-header html-codeβ sets the header text placed at the top of each output file. The header goes to the right of the upper navigation bar. The header can contain HTML tags and white space, but when it does, the header must be enclosed in quotation marks. Use escape characters for internal quotation marks within a header. For example,javadoc -header "<b>My Library</b><br>v1.0" com.mypackage.-helpfile filenameβ includes the file that links to the HELP link in the top and bottom navigation bars. Without this option, thejavadoctool creates a help filehelp-doc.htmlthat's hard-coded into thejavadoctool. This option lets you override the default. Thefilenamecan be any name and isn't restricted tohelp-doc.html. Thejavadoctool adjusts the links in the navigation bar accordingly. For example:- Linux and macOS:
javadoc -helpfile /home/user/myhelp.html java.awt
- Windows:
javadoc -helpfile C:\user\myhelp.html java.awt
-html5β this option is a no-op and is just retained for backwards compatibility. It does literally nothing, it's just here for the vibes π--javafxor-javafxβ enables JavaFX functionality. This option is enabled by default if the JavaFX library classes are detected on the module path. Two spellings, same slay β¨-keywordsβ adds HTML keyword<meta>tags to the generated file for each class. These tags can help search engines that look for<meta>tags find the pages. Most search engines that search the entire internet don't look at<meta>tags, because pages can misuse them. Search engines offered by companies that confine their searches to their own website can benefit by looking at<meta>tags. The<meta>tags include the fully qualified name of the class and the unqualified names of the fields and methods. Constructors aren't included because they're identical to the class name. For example, the classStringstarts with these keywords:
<meta name="keywords" content="java.lang.String class">
<meta name="keywords" content="CASE_INSENSITIVE_ORDER">
<meta name="keywords" content="length()">
<meta name="keywords" content="charAt()">
-link urlβ makes links to javadoc docs that already exist for classes living somewhere else (external refs, iykyk). The url here is the absolute or relative URL of the directory that holds that external javadoc-generated documentation. You can drop multiple-linkoptions in one javadoc tool run to link to multiple documents β stack 'em, bestie β¨
Either a package-list or an element-list file must be in this url directory, otherwise use the -linkoffline option instead. No list file, no link, no cap.
Note: thepackage-listandelement-listfiles are generated by the javadoc tool itself when it generates the API documentation, and should not be modified by the user. Hands off π
When you use the javadoc tool to document packages, it reads the package-list file to figure out which packages are declared in an API. When you generate API docs for modules, it uses the element-list file to figure out which modules and packages are declared in an API. The javadoc tool then reads the names from whichever list file is appropriate and links to those packages or modules at that URL. Iconic behaviour, honestly.
When the javadoc tool runs, the url value gets copied straight into the <A HREF> links it creates. Which is exactly why url has to be the URL to the directory and not to a file. Directory. Not file. Periodt π
You can use an absolute link for url so your docs can link to a document on any web site, or a relative link to only link to a relative location. If you go relative, the value you pass in should be the relative path from the destination directory (specified with the -d option) to the directory containing the packages being linked to. When you specify an absolute link you usually use an HTTP link, but if you want to link to a file system that has no web server, you can use a file link. Use a file link only when everyone who wants to access the generated documentation shares the same file system. And in all cases, on all operating systems, use a slash as the separator β whether the URL is absolute or relative, and https:, http:, or file: as specified in the URL Memo: Uniform Resource Locators [http://www.ietf.org/rfc/rfc1738.txt].
-link https://<host>/<directory>/<directory>/.../<name>
-link http://<host>/<directory>/<directory>/.../<name>
-link file://<host>/<directory>/<directory>/.../<name>
-link <directory>/<directory>/.../<name>
--link-modularity-mismatch (warn|info)β tells the tool how to react when external documentation has the wrong modularity (like, non-modular documentation for a modular library, or the reverse case, messy π). Passwarnto report it as a warning, orinfoto just get a message. The default behavior is to report a warning.-linkoffline url1 url2β a variation of-link, bestie. Both create links to javadoc-generated documentation for externally referenced classes, but this one's for the messy situations. You can specify multiple-linkofflineoptions in one javadoc tool run π«Ά
Use -linkoffline when:
- You're linking to a document on the web that the javadoc tool can't access through a web connection
- The
package-listorelement-listfile of the external document either isn't accessible or doesn't exist at the URL location, but does exist at a different location and can be specified by either thepackage-listorelement-listfile (typically local)
Note: yep, again β thepackage-listandelement-listfiles are generated by the javadoc tool when generating the API documentation and should not be modified by the user. Don't touch πΈ
If url1 is accessible only on the World Wide Web, then -linkoffline removes the constraint that the javadoc tool must have a web connection to generate documentation. Free at last π
Another use of -linkoffline is as a work-around to update documents. After you've run the javadoc tool on a full set of packages or modules, you can run it again on a smaller set of changed packages or modules, so the updated files can be inserted back into the original set. Chef's kiss.
For example, -linkoffline takes two arguments: the first is the string to be embedded in the <a href> links, and the second tells the javadoc tool where to find either the package-list or element-list file.
The url1 or url2 value is the absolute or relative URL of the directory that contains the external javadoc-generated documentation you want to link to. When relative, the value should be the relative path from the destination directory (specified with the -d option) to the root of the packages being linked to. See url in the -link option π
--link-platform-properties urlβ points at a properties file used to configure links to platform documentation. The url argument is expected to point to a properties file containing one or more entries in this exact format, where<version>is the platform version as passed to the--releaseor--sourceoption and<url>is the base URL of the corresponding platform API documentation:
doclet.platform.docs.<version>=<url>
For instance, a properties file containing URLs for releases 15 to 17 might contain the following lines:
doclet.platform.docs.15=https://example.com/api/15/
doclet.platform.docs.16=https://example.com/api/16/
doclet.platform.docs.17=https://example.com/api/17/
If the properties file doesn't contain an entry for a particular release, no platform links are generated. Simple as that β¨
-linksourceβ creates an HTML version of each source file (with line numbers, cute) and adds links to them from the standard HTML documentation. Links get created for classes, interfaces, constructors, methods, and fields whose declarations are in a source file. Otherwise, no links β like for default constructors and generated classes. Nothing to link, nothing to see.
β οΈ Heads up: this option exposes all private implementation details in the included source files, including private classes, private fields, and the bodies of private methods β regardless of the-public,-package,-protected, and-privateoptions. Unless you also use the-privateoption, not all private classes or interfaces are accessible through links. So like, be aware π
Each link appears on the name of the identifier in its declaration. For example, the link to the source code of the Button class would be on the word Button:
public class Button extends Component implements Accessible
And the link to the source code of the getLabel method in the Button class is on the word getLabel:
public String getLabel()
--main-stylesheet fileor-stylesheetfile fileβ specifies the path of an alternate stylesheet file containing the definitions for the CSS styles used in the generated documentation. This one lets you override the default π If you don't specify the option, the javadoc tool creates and uses a default stylesheet. The file name can be any name and isn't restricted tostylesheet.css. Also,--main-stylesheetis the preferred form, so use that one, bestie.
Command-line example:
javadoc --main-stylesheet main_stylesheet.css pkg_foo
-nocommentβ suppresses the entire comment body, including the main description and all tags, and generates only declarations. This lets you reuse source files that were originally intended for a different purpose, so you can produce skeleton HTML documentation during the early stages of a new project. Skeleton docs era π¦-nodeprecatedβ prevents the generation of any deprecated API in the documentation. It does what the-nodeprecatedlistoption does, and it doesn't generate any deprecated API throughout the rest of the documentation. Super useful when you're writing code and don't want to be distracted by the deprecated stuff. Out of sight, out of mind π-nodeprecatedlistβ prevents the generation of the file containing the list of deprecated APIs (deprecated-list.html) and the link in the navigation bar to that page. The javadoc tool continues to generate the deprecated API throughout the rest of the document though β it just hides the list. Useful when your source code contains no deprecated APIs and you want the navigation bar cleaner. Aesthetic β¨-nohelpβ omits the HELP link in the navigation bar at the top of each page of output. Bye bestie π-noindexβ omits the index from the generated documents. The index is produced by default, just so you know.-nonavbarβ prevents the generation of the navigation bar, header, and footer that are usually found at the top and bottom of the generated pages. Got it? Kay.
The -nonavbar option has no effect on the -bottom option. And it's useful when you're interested only in the content and have no need for navigation β like when you're converting the files to PostScript or PDF for printing only. Printing girls rise up π
--no-platform-linksβ prevents the generation of links to platform documentation. Those links are generated by default, so this is the opt-out π«Ά-noqualifier name1,name2...β excludes the list of qualifiers from the output. The package name gets removed from places where class or interface names appear. For historical reasons,:can be used anywhere in the argument as a separator instead of,. Weird but true, iykyk.
The following example omits all package qualifiers: -noqualifier all.
The following example omits java.lang and java.io package qualifiers: -noqualifier java.lang:java.io.
The following example omits package qualifiers starting with java and com.sun subpackages, but not javax: -noqualifier java.*:com.sun.*.
Where a package qualifier would appear due to the previous behavior, the name can be suitably shortened. And this rule is in effect whether or not the -noqualifier option is used. Sneaky but slay π
-nosinceβ omits from the generated documents theSincesections associated with the@sincetags. No since for you π¦-notimestampβ hides the time stamp that normally lurks in an HTML comment near the top of every generated page π. Honestly? Kind of iconic for diffing: runjavadocon two source bases and diff them, and without this you'd get a diff on every single page just because the clock ticked π°οΈ. Heads up tho β the time stamp also includes thejavadoctool release number, so that's part of what you're hiding.-notreeβ no class and interface hierarchy pages for you, bestie π«π³. Those are the pages you get by clicking the Tree button in the navigation bar. The hierarchy is produced by default, so this is you actively choosing chaos-free output.--override-methods (detail|summary)β says where to document overridden methods: in the detail sections or the summary sections. Default isdetail, no cap.-overviewfilename β tellsjavadocto go grab the overview documentation text from the source file you name in filename and drop it on the Overview page (overview-summary.html) β¨. A relative path in that file name is relative to the current working directory.
You can literally name the file whatever and put it wherever your heart desires π, but the classic move is calling it overview.html and parking it in the source tree at the directory that holds the topmost package directories. Why? Because in that spot you don't need a path at all when documenting packages β the -sourcepath option is already pointing at that file π―.
- Linux and macOS: say your source tree for the
java.langpackage issrc/classes/java/lang/β then you'd put the overview file atsrc/classes/overview.html. - Windows: say your source tree for the
java.langpackage issrc\classes\java\lang\β then you'd put the overview file atsrc\classes\overview.html.
Important vibe check: the overview page only gets created when you pass two or more package names to thejavadoctool. And the title on that overview page is set by-doctitle.
-serialwarnβ generates compile-time warnings for missing@serialtags π. By default,Javadocgenerates no serial warnings at all. Flip this on to actually see them, which helps you properly document default serializable fields andwriteExternalmethods. Future you says thank you π«Ά.--since*release(,release)** β generates documentation for APIs that were added or newly deprecated in the releases you list π . Multiple releases? Comma-separate them, bestie.
Here's the tea: if the @since tag in the javadoc comment of a documented element matches a release you passed as an option argument, info about that element and the release it was added in gets included on a "New API" page.
And if the "Deprecated API" page is being generated and the since element of the java.lang.Deprecated annotation of a documented element matches a release in your option arguments, info about the release it was deprecated in gets added to the "Deprecated API" page.
Releases are compared using case-sensitive string comparison. Capital letters matter, periodt π .
--since-labeltext β the text used in the heading of the "New API" page π. It can carry info about the releases covered on the page, e.g."New API in release 2.0", or"New API since release 1".--snippet-pathsnippetpathlist β the search paths for finding files for external snippets π. snippetpathlist can hold multiple paths, separated by the platform path separator (;on Windows,:on other platforms). The Standard Doclet first searches thesnippet-filessubdirectory in the package containing the snippet, and then searches all the directories in the list you gave it.-sourcetabtab-length β how many spaces each tab counts for in the source. That's it, that's the whole option π.--spec-base-urlurl β the base URL for relative URLs in@spectags, used when generating links to any external specifications π. It can be an absolute URL, or a relative URL β and if it's relative, it gets evaluated relative to the base directory of the generated output files. Default value is equivalent to{@docRoot}/../specs.-splitindexβ splits the index file into multiple files, alphabetically, one file per letter π °οΈπ ±οΈπ ², plus a file for any index entries that start with non-alphabetical symbols. Organized queen behaviour.-tagname:locations:header β sets up single-argument custom tags π·οΈ. Real talk: for thejavadoctool to spell-check tag names, it's important that you include a-tagoption for every custom tag present in the source code β disabling (withX) the ones that aren't being output in the current run. The colon (:) is always the separator. Need a literal colon in the tag name? Escape it with a backward slash (\).
The -tag option outputs the tag heading, header, in bold, followed on the next line by the text from its single argument. Just like any block tag, the argument text can contain inline tags, which also get interpreted β¨. The output is similar to standard one-argument tags such as @return and @author. Omit a header value and the name becomes the heading.
locations is a list of characters saying which kinds of declarations the tag may be used in, and you can use uppercase or lowercase:
A: all declarationsC: constructorsF: fieldsM: methodsO: the overview page and other documentation files indoc-filessubdirectoriesP: packagesS: modulesT: types (classes and interfaces)X: nowhere β the tag is disabled and will be ignored π
The order you give tags on the command line is the order they appear in the generated output. And you can slot standard tags into that order by using the -tag option with no locations or header β chef's kiss ordering control π
-tagletclass β the fully qualified name of the taglet used to generate the documentation for that tag. Use the fully qualified name for the class value. This taglet also defines how many text arguments the custom tag has β it accepts those arguments, processes them, and generates the output π«.
Taglets are useful for block or inline tags. They can have any number of arguments and implement custom behavior, like making text bold, formatting bullets, writing text out to a file, or starting other processes. But here's the limit, and it's real: taglets can only determine where a tag should appear and in what form. Every other decision is made by the doclet. A taglet can't do things like remove a class name from the list of included classes. It can execute side effects though β printing the tag's text to a file, triggering another process, that kind of main character energy. Use the -tagletpath option to specify the path to the taglet.
This example inserts the To Do taglet after Parameters and ahead of Throws in the generated pages:
-taglet com.sun.tools.doclets.ToDoTaglet
-tagletpath /home/taglets
-tag return
-tag param
-tag todo
-tag throws
-tag see
Alternately you can use the -taglet option in place of its -tag option β but ngl that might be difficult to read π.
-tagletpathtagletpathlist β the search paths for finding taglet class files π. tagletpathlist can contain multiple paths separated by the platform path separator (;on Windows,:on other platforms). Thejavadoctool searches all subdirectories of the specified paths.-tophtml-code β the text that goes at the top of each output file β¬οΈβ¨.-useβ creates class and package usage pages, one Use page for each documented class and package π₯. The page describes what packages, classes, methods, constructors and fields use any API of the specified class or package.
Given class C, things that use class C would include subclasses of C, fields declared as C, methods that return C, and methods and constructors with parameters of type C. For example, you can look at the Use page for the String type β because the getName method in the java.awt.Font class returns type String, the getName method uses String and so the getName method appears on the Use page for String π§΅.
This documents only uses of the API, not the implementation. So when a method uses String in its implementation but doesn't take a string as an argument or return a string, that isn't considered a use of String. To access the generated Use page, go to the class or package and click the Use link in the navigation bar π±οΈ.
-versionβ includes the version text in the generated docs. This text is omitted by default. Wanna know what version of thejavadoctool you're using? That's the-J-versionoption, bestie π.-windowtitletitle β the title placed in the HTML<title>tag πͺ. The text you specify in the title tag appears in the window title and in any browser bookmarks (favorite places) that someone creates for this page.
Keep HTML tags out of this title β a browser won't interpret them correctly π . Use escape characters on any internal quotation marks within the title tag.
If the -windowtitle option is omitted, then the javadoc tool uses the value of the -doctitle option for the -windowtitle option. Example: javadoc -windowtitle "My Library" com.mypackage.
β¨ Extra Options for the Standard Doclet β¨
Okay so these next ones are extra options provided by the Standard Doclet, and they are subject to change without notice β οΈ β so don't get too attached. They're also less commonly used, or otherwise regarded as advanced. Advanced bestie hours π§π
--datedate-and-time β sets the timestamp stamped onto the pages you generate, and it's gotta be in ISO 8601 format (the whole date-and-time-for-mat.html situation, iykyk). Two things to know, bestie: the value must be within 10 years of the current date and time, and specifying both-notimestampand--dateis literally an error. Why would you even want this? Because pinning a specific value means your generated docs can be part of a reproducible build (that's reproducible-builds.org, slay). Don't pass the option at all and the default is just the current date and time. Like so:
javadoc --date 2022-02-01T17:41:59-08:00 mypackage
--legal-notices(default|none|directory) β tells javadoc where to copy legal files from, into the generated docs. Leave the option off entirely, or use it with the valuedefault, and the files get copied from the default location. Use it with the valuenoneand nothing gets copied at all, zero files, nada. Any other argument? That gets interpreted as a directory to copy the legal files from. π--no-framesβ this one's a no-op, a total vibe that does nothing. It's just retained for backwards compatibility. Not me keeping a flag around purely out of nostalgia π-Xdoclintβ turns on the recommended checks for problems in your documentation comments. And surprise: it's enabled by default. Turn it off with-Xdoclint:none. More deets in DocLint, below.- *
-Xdoclint:flag,flag,...* β enable or disable specific checks for different kinds of issues in documentation comments. Each flag can be one ofall,none, or[-]group, where group has one of these values:accessibility,html,missing,reference,syntax. More on those values in DocLint Groups.
When you're specifying two or more flags you've got options, bestie: either one single -Xdoclint:... option listing all the flags you want, or multiple options each carrying one or more flag. Both work. For example, either of these commands checks for the HTML, syntax, and accessibility issues in the file MyFile.java:
javadoc -Xdoclint:html -Xdoclint:syntax -Xdoclint:accessibility MyFile.java
javadoc -Xdoclint:html,syntax,accessibility MyFile.java
And here's how you change what DocLint actually reports:
-Xdoclint:noneβ disables all checks-Xdoclint:groupβ enables group checks-Xdoclint:allβ enables all groups of checks-Xdoclint:all,-groupβ enables all checks except group checks
For more details, see DocLint.
-Xdoclint/package:[-]packages β enables or disables checks in specific packages. packages is a comma separated list of package specifiers. A package specifier is either a qualified name of a package, or a package name prefix followed by*, which expands to all subpackages of the given package. Prefix the package specifier with-to disable checks for those packages. For more details, see DocLint.-Xdocrootparenturl β replaces all@docRootitems followed by/..in documentation comments with url. Swapsies β¨
π DOCLINT π
DocLint is the girl who checks for possible problems in your documentation comments. Problems get reported as warnings or errors depending on how serious they are. For example, a missing comment might just be bad style that deserves a warning, but a link to an unknown Java declaration is way more serious and deserves an error, periodt. Problems are organized into groups, and you can use options to enable or disable messages in one or more groups. And inside the source code itself, messages in one or more groups can be suppressed using @SuppressWarnings annotations.
When it's invoked from javadoc, DocLint by default checks all comments used in the generated documentation. Which means it relies on the other command-line options to figure out which declarations β and which corresponding documentation comments β will actually be included. Heads up: this may mean even comments on some private members of serializable classes get checked too, if those members need to be documented in the generated Serialized Forms page. π
In contrast, when DocLint is invoked from javac, it solely relies on the various -Xdoclint... options to determine which documentation comments to check. Different energy entirely.
DocLint doesn't attempt to fix invalid input β it just reports it. No fixing, only reading you to filth π
Note: DocLint doesn't guarantee the completeness of these checks. In particular, it isn't a full HTML compliance checker. The goal is just to report common errors in a convenient manner.
πΈ Groups πΈ
The checks DocLint performs are organized into groups. The warnings and errors in each group can be enabled or disabled with command-line options, or suppressed with @SuppressWarnings annotations. The groups are:
accessibilityβ checks for issues related to accessibility. For example, noaltattribute specified in an<img>element, or nocaptionorsummaryattributes specified in a<table>element.
These issues are reported as errors if a downstream validation tool might be expected to report an error in the files generated by javadoc.
For reference, see the Web Content Accessibility Guidelines (w3.org/WAI/standards-guidelines/wcag/).
htmlβ detects common high-level HTML issues. For example, putting block elements inside inline elements, or not closing elements that require an end tag.
These issues are reported as errors if a downstream validation tool might be expected to report an error in the files generated by javadoc.
For reference, see the HTML Living Standard (html.spec.whatwg.org/multipage/).
missingβ checks for missing documentation comments or tags. For example, a missing comment on a class declaration, or a missing@paramor@returntag in the comment for a method declaration.
Issues related to missing items are typically reported as warnings, because they're unlikely to be reported as errors by downstream validation tools that may be used to check the output generated by javadoc.
referenceβ checks for issues relating to the references to Java API elements from documentation comment tags. For example, the reference in@seeor{@link ...}cannot be found, or a bad name is given for@paramor@throws.
These issues are typically reported as errors, because while the issue may not cause problems in the generated files, the author has likely made a mistake that will lead to incorrect or unexpected documentation. π
syntaxβ checks for low-level syntactic issues in documentation comments. For example, unescaped angle brackets (<and>) and ampersands (&) and invalid documentation comment tags.
These are typically reported as errors, because the issues may lead to incorrect or unexpected documentation.
π€« Suppressing Messages π€«
DocLint checks for and recognizes two strings that may be present in the arguments for an @SuppressWarnings annotation:
doclintdoclint:LIST
where LIST is a comma-separated list of one or more of accessibility, html, missing, syntax, reference.
The names in LIST are the same group names supported by the command-line -Xdoclint option for javac and javadoc. (This is the same convention honored by the javac -Xlint option and the corresponding names supported by @SuppressWarnings.) π«Ά
The names in LIST can equivalently be specified in separate arguments of the annotation. For example, these two are equivalent:
@SuppressWarnings("doclint:accessibility,missing")@SuppressWarnings("doclint:accessibility", "doclint:missing")
When DocLint detects an issue in a documentation comment, it checks for the presence of @SuppressWarnings on the associated declaration and on all lexically enclosing declarations. The issue will be ignored if any such annotation is found containing the simple string doclint, or the longer form doclint:LIST where LIST contains the name of the group for the issue.
Note: as with other uses of @SuppressWarnings, using the annotation on a module or package declaration only affects that declaration; it does not affect the contents of the module or package in other source files.
All messages related to an issue are suppressed by the presence of an appropriate @SuppressWarnings annotation β and yes, that includes errors as well as warnings.
Note: it's only possible to suppress messages. If an annotation of @SuppressWarnings("doclint") is given on a top-level declaration, all DocLint messages for that declaration and any enclosed declarations will be suppressed; it is not possible to selectively re-enable messages for issues in enclosed declarations. Once it's silenced, it's silenced π
βοΈ Comparison with downstream validation tools βοΈ
DocLint is a utility built into javac and javadoc that checks the content of documentation comments, as found in source files. Downstream validation tools, on the other hand, validate the output generated from those documentation comments by javadoc and the Standard Doclet. There's some overlap in functionality, but the two mechanisms are different and each has its own strengths and weaknesses:
- Downstream validation tools can check the end result of any generated documentation, exactly as it will be seen by the end user. That includes content from all sources β documentation comments, the Standard Doclet itself, user-provided taglets, and content supplied via command-line options. Because such tools analyze complete HTML pages, they can do more complete checks than DocLint can. But when a problem is found in the generated pages, it can be harder to track down exactly where in the build pipeline the problem needs to be fixed. π₯
- DocLint checks the content of documentation comments, in source files. That makes it super easy to identify the exact position of any issues found. DocLint can also detect some semantic errors in documentation comments that downstream tools cannot, like missing comments, using an
@returntag in a method returningvoid, or an@paramtag describing a non-existent parameter. But by its nature, DocLint cannot report on problems such as missing links, or errors in user-provided custom taglets, or problems in the Standard Doclet itself. It also cannot reliably detect errors in documentation comments at the boundaries between content in a documentation comment and content generated by a custom taglet. It's giving different tools for different jobs, and that's iconic π
And that's the whole page, bestie β you ate that π This particular flavor of the manual is from JDK 21, dated 2023, under the name JAVADOC(1). Go forth and document, queen πβ¨
π¦ where this page comes from
- arch rolling: jdk21-openjdk 21.0.13.0.3.u1-1 Β· LicenseRef-Java
- Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms