javadoc
Generate Java documentation from source code
TLDR
Generate documentation for Java source code and save the result in a directory
Generate documentation with a specific encoding
Generate documentation excluding some packages
SYNOPSIS
javadoc [options] [packagenames] [sourcefiles] [@files]
PARAMETERS
-d
Specifies the destination directory where the generated HTML files will be saved.
-sourcepath
Specifies the source file search path. Multiple paths are separated by colons (:) on Unix-like systems or semicolons (;) on Windows.
-classpath
Specifies the classpath to be used. Multiple paths are separated by colons (:) on Unix-like systems or semicolons (;) on Windows.
-subpackages
Generates documentation for all subpackages below the specified packages.
-exclude
Specifies a list of packages to exclude from documentation generation.
-private
Includes all classes and members in the generated documentation, including private ones.
-package
Includes package-private classes and members.
-protected
Includes protected and public classes and members. (default)
-public
Includes only public classes and members.
-version
Includes the `@version` tag in the generated documentation.
-author
Includes the `@author` tag in the generated documentation.
-use
Creates use pages for each documented class and package.
-splitindex
Splits the index file into multiple files, one per letter.
-windowtitle
Specifies the browser window title.
-doctitle
Specifies the document title for the overview page.
-header
Specifies the header text to be placed on each page.
-bottom
Specifies the bottom text to be placed on each page.
-footer
Specifies the footer text to be placed at the bottom of each page.
-link
Creates links to javadoc documentation at
-linkoffline
Same as -link except javadoc can access offline, uses
-quiet
Suppresses all javadoc messages except for errors and warnings.
DESCRIPTION
The javadoc command is a tool for generating API documentation in HTML format from Java source code. It parses the declarations and documentation comments in a set of Java source files and creates a set of interconnected HTML pages describing the classes, interfaces, constructors, methods, and fields in those files. This documentation is extremely valuable for developers to understand and use Java libraries and applications. It relies on specially formatted comments, known as 'Javadoc comments,' embedded within the source code. These comments begin with `/**` and end with `*/`. The javadoc tool interprets tags within these comments (e.g., `@param`, `@return`, `@throws`, `@see`) to structure the resulting documentation. The output is typically organized into a hierarchy of HTML pages, including an index, class summaries, and detailed descriptions of each element.
CAVEATS
The quality of the generated documentation is heavily dependent on the presence and correctness of Javadoc comments in the source code. Incorrect or missing tags can lead to incomplete or misleading documentation.
The specific appearance of the generated documentation can vary depending on the doclet being used. The standard doclet is used by default.
DOCLETS
Doclets are programs written in Java that determine the output format of the Javadoc tool. The standard doclet generates HTML, but custom doclets can be written to generate output in other formats such as XML, PDF, or plain text.
JAVADOC TAGS
Javadoc tags are special markers within Javadoc comments that provide metadata about the documented element. Common tags include `@param`, `@return`, `@throws`, `@see`, `@author`, and `@version`. These tags are crucial for structuring the documentation and conveying important information to users.
EXAMPLE
javadoc -d docs -sourcepath src com.example
This command will generate documentation for all classes in the com.example package, placing the output in the 'docs' directory, with source code in the 'src' directory.
HISTORY
The javadoc tool was initially released as part of the Java Development Kit (JDK) in 1995 by Sun Microsystems (later acquired by Oracle). It was designed to address the need for standardized and easily accessible API documentation for Java libraries and applications. Over time, javadoc has become an essential part of the Java development workflow, used by countless projects to generate high-quality documentation. The format and feature set of javadoc have evolved with new versions of Java, adding support for new language features and improving the documentation generation process.
SEE ALSO
java(1)