This example Java source code file (javadoc.1) is included in the alvinalexander.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
for, html, java, javadoc, see, the, this, when, you
The javadoc.1 Java example source code
'\" t
.\" Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
.\"
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\" Arch: generic
.\" Software: JDK 8
.\" Date: 10 May 2011
.\" SectDesc: Basic Tools
.\" Title: javadoc.1
.\"
.if n .pl 99999
.TH javadoc 1 "10 May 2011" "JDK 8" "Basic Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH NAME
javadoc \- Generates HTML pages of API documentation from Java source files\&.
.SH SYNOPSIS
.sp
.nf
\fBjavadoc\fR {\fIpackages\fR|\fIsource\-files\fR} [\fIoptions\fR] [\fI@argfiles\fR]
.fi
.sp
.TP
\fIpackages\fR
Names of packages that you want to document, separated by spaces, for example \f3java\&.lang java\&.lang\&.reflect java\&.awt\fR\&. If you want to also document the subpackages, use the \f3-subpackages\fR option to specify the packages\&.
By default, \f3javadoc\fR looks for the specified packages in the current directory and subdirectories\&. Use the \f3-sourcepath\fR option to specify the list of directories where to look for packages\&.
.TP
\fIsource-files\fR
Names of Java source files that you want to document, separated by spaces, for example \f3Class\&.java Object\&.java Button\&.java\fR\&. By default, \f3javadoc\fR looks 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 \f3/home/src/java/awt/Graphics*\&.java\fR\&. You can also specify the path relative to the current directory\&.
.TP
\fIoptions\fR
Command-line options, separated by spaces\&. See Options\&.
.TP
\fI@argfiles\fR
Names of files that contain a list of \f3javadoc\fR command options, package names and source file names in any order\&.
.SH DESCRIPTION
The \f3javadoc\fR command parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields\&. You can use the \f3javadoc\fR command to generate the API documentation or the implementation documentation for a set of source files\&.
.PP
You can run the \f3javadoc\fR command on entire packages, individual source files, or both\&. When documenting entire packages, you can either use the \f3-subpackages\fR option 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\&. See Simple Examples\&.
.SS PROCESS\ SOURCE\ FILES
The \f3javadoc\fR command processes files that end in source and other files described in Source Files\&. If you run the \f3javadoc\fR command by passing in individual source file names, then you can determine exactly which source files are processed\&. However, that is not how most developers want to work, because it is simpler to pass in package names\&. The \f3javadoc\fR command can be run three ways without explicitly specifying the source file names\&. You can pass in package names, use the \f3-subpackages\fR option, or use wild cards with source file names\&. In these cases, the \f3javadoc\fR command processes a source file only when the file fulfills all of the following requirements:
.TP 0.2i
\(bu
The file name prefix (with \f3\&.java\fR removed) is a valid class name\&.
.TP 0.2i
\(bu
The path name relative to the root of the source tree is a valid package name after the separators are converted to dots\&.
.TP 0.2i
\(bu
The package statement contains the valid package name\&.
.PP
Processing Links
During a run, the \f3javadoc\fR command adds cross-reference links to package, class, and member names that are being documented as part of that run\&. Links appear in the following places\&. See Javadoc Tags for a description of the @ tags\&.
.TP 0.2i
\(bu
Declarations (return types, argument types, and field types)\&.
.TP 0.2i
\(bu
\fISee Also\fR sections that are generated from \f3@see\fR tags\&.
.TP 0.2i
\(bu
Inline text generated from \f3{@link}\fR tags\&.
.TP 0.2i
\(bu
Exception names generated from \f3@throws\fR tags\&.
.TP 0.2i
\(bu
\fISpecified by\fR links to interface members and \fIOverrides\fR links to class members\&. See Method Comment Inheritance\&.
.TP 0.2i
\(bu
Summary tables listing packages, classes and members\&.
.TP 0.2i
\(bu
Package and class inheritance trees\&.
.TP 0.2i
\(bu
The index\&.
.PP
You can add links to existing text for classes not included on the command line (but generated separately) by way of the \f3-link\fR and \f3-linkoffline\fR options\&.
.PP
Processing Details
The \f3javadoc\fR command produces one complete document every time it runs\&. It does not do incremental builds that modify or directly incorporate the results from earlier runs\&. However, the \f3javadoc\fR command can link to results from other runs\&.
.PP
The \f3javadoc\fR command implementation requires and relies on the Java compiler\&. The \f3javadoc\fR command calls part of the \f3javac\fR command to compile the declarations and ignore the member implementations\&. The \f3javadoc\fR command builds a rich internal representation of the classes that includes the class hierarchy and use relationships to generate the HTML\&. The \f3javadoc\fR command also picks up user-supplied documentation from documentation comments in the source code\&. See Documentation Comments\&.
.PP
The \f3javadoc\fR command runs on source files that are pure stub files with no method bodies\&. This means you can write documentation comments and run the \f3javadoc\fR command in the early stages of design before API implementation\&.
.PP
Relying on the compiler ensures that the HTML output corresponds exactly with the actual implementation, which may rely on implicit, rather than explicit, source code\&. For example, the \f3javadoc\fR command documents default constructors that are present in the compiled class files but not in the source code\&.
.PP
In many cases, the \f3javadoc\fR command lets you generate documentation for source files with incomplete or erroneous code\&. You can generate documentation before all debugging and troubleshooting is done\&. The \f3javadoc\fR command does primitive checking of documentation comments\&.
.PP
When the \f3javadoc\fR command builds its internal structure for the documentation, it loads all referenced classes\&. Because of this, the \f3javadoc\fR command must be able to find all referenced classes, whether bootstrap classes, extensions, or user classes\&. See How Classes Are Found at http://docs\&.oracle\&.com/javase/8/docs/technotes/tools/findingclasses\&.html
.PP
Typically, classes you create must either be loaded as an extension or in the \f3javadoc\fR command class path\&.
.SS JAVADOC\ DOCLETS
You can customize the content and format of the \f3javadoc\fR command output with doclets\&. The \f3javadoc\fR command has a default built-in doclet, called the standard doclet, that generates HTML-formatted API documentation\&. You can modify or make a subclass of the standard doclet, or write your own doclet to generate HTML, XML, MIF, RTF or whatever output format you want\&.
.PP
When a custom doclet is not specified with the \f3-doclet\fR option, the \f3javadoc\fR command uses the default standard doclet\&. The \f3javadoc\fR command has several options that are available regardless of which doclet is being used\&. The standard doclet adds a supplementary set of command-line options\&. See Options\&.
.SH SOURCE\ FILES
The \f3javadoc\fR command generates output that originates from the following types of source files: Java language source files for classes (\f3\&.java\fR), package comment files, overview comment files, and miscellaneous unprocessed files\&. This section also describes test files and template files that can also be in the source tree, but that you want to be sure not to document\&.
.SS CLASS\ SOURCE\ FILES
Each class or interface and its members can have their own documentation comments contained in a source file\&. See Documentation Comments\&.
.SS PACKAGE\ COMMENT\ FILES
Each package can have its own documentation comment, contained in its own source file, that the \f3javadoc\fR command merges into the generated package summary page\&. You typically include in this comment any documentation that applies to the entire package\&.
.PP
To create a package comment file, you can place your comments in one of the following files:
.TP 0.2i
\(bu
The \f3package-info\&.java\fR file can contain the package declaration, package annotations, package comments, and Javadoc tags\&. This file is preferred\&.
.TP 0.2i
\(bu
The \f3package\&.html\fR file contains only package comments and Javadoc tags\&. No package annotations\&.
.PP
A package can have a single \f3package\&.html\fR file or a single \f3package-info\&.java\fR file, but not both\&. Place either file in the package directory in the source tree with your source files\&.
.PP
The package-info\&.java File
The \f3package-info\&.java\fR file can contain a package comment of the following structure\&. The comment is placed before the package declaration\&.
.PP
\fINote:\fR The comment separators \f3/**\fR and \f3*/\fR must be present, but the leading asterisks on the intermediate lines can be left off\&.
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * Provides the classes necessary to create an \fP
.fi
.nf
\f3 * applet and the classes an applet uses \fP
.fi
.nf
\f3 * to communicate with its applet context\&.\fP
.fi
.nf
\f3 * <p>\fP
.fi
.nf
\f3 * The applet framework involves two entities:\fP
.fi
.nf
\f3 * the applet and the applet context\&.\fP
.fi
.nf
\f3 * An applet is an embeddable window (see the\fP
.fi
.nf
\f3 * {@link java\&.awt\&.Panel} class) with a few extra\fP
.fi
.nf
\f3 * methods that the applet context can use to \fP
.fi
.nf
\f3 * initialize, start, and stop the applet\&.\fP
.fi
.nf
\f3 *\fP
.fi
.nf
\f3 * @since 1\&.0\fP
.fi
.nf
\f3 * @see java\&.awt\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3package java\&.lang\&.applet;\fP
.fi
.nf
\f3\fR
.fi
.sp
.PP
The package\&.html File
The \f3package\&.html\fR file can contain a package comment of the following structure\&. The comment is placed in the \f3<body>\fR element\&.
.PP
File: \f3java/applet/package\&.html\fR
.sp
.nf
\f3<HTML>\fP
.fi
.nf
\f3<BODY>\fP
.fi
.nf
\f3Provides the classes necessary to create an applet and the \fP
.fi
.nf
\f3classes an applet uses to communicate with its applet context\&.\fP
.fi
.nf
\f3<p>\fP
.fi
.nf
\f3The applet framework involves two entities: the applet\fP
.fi
.nf
\f3and the applet context\&. An applet is an embeddable\fP
.fi
.nf
\f3window (see the {@link java\&.awt\&.Panel} class) with a\fP
.fi
.nf
\f3few extra methods that the applet context can use to\fP
.fi
.nf
\f3initialize, start, and stop the applet\&. \fP
.fi
.nf
\f3\fR
.fi
.nf
\f3@since 1\&.0 \fP
.fi
.nf
\f3@see java\&.awt\fP
.fi
.nf
\f3</BODY>\fP
.fi
.nf
\f3</HTML>\fP
.fi
.nf
\f3\fR
.fi
.sp
The \f3package\&.html\fR file is a typical HTML file and does not include a package declaration\&. The content of the package comment file is written in HTML with one exception\&. The documentation comment should not include the comment separators \f3/**\fR and \f3*/\fR or leading asterisks\&. When writing the comment, make the first sentence a summary about the package, and do not put a title or any other text between the \f3<body>\fR tag and the first sentence\&. You can include package tags\&. All block tags must appear after the main description\&. If you add an \f3@see\fR tag in a package comment file, then it must have a fully qualified name\&.
.PP
Processing the Comment File
When the \f3javadoc\fR command runs, it searches for the package comment file\&. If the package comment file is found, then the \f3javadoc\fR command does the following:
.TP 0.2i
\(bu
Copies the comment for processing\&. For package\&.html, the \f3javadoc\fR command copies all content between the \f3<body>\fR and \f3
\fR HTML tags\&. You can include a \f3
\fR section to put a \f3
\fR tag, source file copyright statement, or other information, but none of these appear in the generated documentation\&.
.TP 0.2i
\(bu
Processes the package tags\&. See Package Tags\&.
.TP 0.2i
\(bu
Inserts the processed text at the bottom of the generated package summary page\&. See Java Platform, Standard Edition API Specification Overview at http://docs\&.oracle\&.com/javase/8/docs/api/overview-summary\&.html
.TP 0.2i
\(bu
Copies the first sentence of the package comment to the top of the package summary page\&. The \f3javadoc\fR command also adds the package name and this first sentence to the list of packages on the overview page\&. See Java Platform, Standard Edition API Specification Overview at http://docs\&.oracle\&.com/javase/8/docs/api/overview-summary\&.html
The end of the sentence is determined by the same rules used for the end of the first sentence of class and member main descriptions\&.
.SS OVERVIEW\ COMMENT\ FILES
Each application or set of packages that you are documenting can have its own overview documentation comment that is kept in its own source file, that the \f3javadoc\fR command merges into the generated overview page\&. You typically include in this comment any documentation that applies to the entire application or set of packages\&.
.PP
You can name the file anything you want such as overview\&.html and place it anywhere\&. A typical location is at the top of the source tree\&.
.PP
For example, if the source files for the \f3java\&.applet\fR package are contained in the /home/user/src/java/applet directory, then you could create an overview comment file at /home/user/src/overview\&.html\&.
.PP
You can have multiple overview comment files for the same set of source files in case you want to run the \f3javadoc\fR command multiple times on different sets of packages\&. For example, you could run the \f3javadoc\fR command once with \f3-private\fR for internal documentation and again without that option for public documentation\&. In this case, you could describe the documentation as public or internal in the first sentence of each overview comment file\&.
.PP
The content of the overview comment file is one big documentation comment that is written in HTML\&. Make the first sentence a summary about the application or set of packages\&. Do not put a title or any other text between the \f3<body>\fR tag and the first sentence\&. All tags except inline tags, such as an {\f3@link}\fR tag, must appear after the main description\&. If you add an \f3@see\fR tag, then it must have a fully qualified name\&.
.PP
When you run the \f3javadoc\fR command, specify the overview comment file name with the \f3-overview\fR option\&. The file is then processed similarly to that of a package comment file\&. The \f3javadoc\fR command does the following:
.TP 0.2i
\(bu
Copies all content between the \f3<body>\fR and \f3\fR tags for processing\&.
.TP 0.2i
\(bu
Processes the overview tags that are present\&. See Overview Tags\&.
.TP 0.2i
\(bu
Inserts the processed text at the bottom of the generated overview page\&. See Java Platform Standard Edition API Specification Overview at http://docs\&.oracle\&.com/javase/8/docs/api/overview-summary\&.html
.TP 0.2i
\(bu
Copies the first sentence of the overview comment to the top of the overview summary page\&.
.SS UNPROCESSED\ FILES
Your source files can include any files that you want the \f3javadoc\fR command to copy to the destination directory\&. These files usually include graphic files, example Java source and class files, and self-standing HTML files with a lot of content that would overwhelm the documentation comment of a typical Java source file\&.
.PP
To include unprocessed files, put them in a directory called doc-files\&. The doc-files directory can be a subdirectory of any package directory that contains source files\&. You can have one doc-files subdirectory for each package\&.
.PP
For example, if you want to include the image of a button in the \f3java\&.awt\&.Button\fR class documentation, then place the image file in the /home/user/src/java/awt/doc-files/ directory\&. Do not place the doc-files directory at /home/user/src/java/doc-files, because java is not a package\&. It does not contain any source files\&.
.PP
All links to the unprocessed files must be included in the code because the \f3javadoc\fR command does not look at the files\&. The \f3javadoc\fR command copies the directory and all of its contents to the destination\&. The following example shows how the link in the Button\&.java documentation comment might look:
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * This button looks like this: \fP
.fi
.nf
\f3 * <img src="doc\-files/Button\&.gif">\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3\fR
.fi
.sp
.SS TEST\ AND\ TEMPLATE\ FILES
You can store test and template files in the source tree in the same directory with or in a subdirectory of the directory where the source files reside\&. To prevent test and template files from being processed, run the \f3javadoc\fR command and explicitly pass in individual source file names\&.
.PP
Test files are valid, compilable source files\&. Template files are not valid, compatible source files, but they often have the \f3\&.java\fR suffix\&.
.PP
Test Files
If you want your test files to belong to either an unnamed package or to a package other than the package that the source files are in, then put the test files in a subdirectory underneath the source files and give the directory an invalid name\&. If you put the test files in the same directory with the source and call the \f3javadoc\fR command with a command-line argument that indicates its package name, then the test files cause warnings or errors\&. If the files are in a subdirectory with an invalid name, then the test file directory is skipped and no errors or warnings are issued\&. For example, to add test files for source files in com\&.package1, put them in a subdirectory in an invalid package name\&. The following directory name is invalid because it contains a hyphen:
.sp
.nf
\f3com/package1/test\-files/\fP
.fi
.nf
\f3\fR
.fi
.sp
If your test files contain documentation comments, then you can set up a separate run of the \f3javadoc\fR command to produce test file documentation by passing in their test source file names with wild cards, such as \f3com/package1/test-files/*\&.java\fR\&.
.PP
Template Files
If you want a template file to be in the source directory, but not generate errors when you execute the \f3javadoc\fR command, then give it an invalid file name such as \f3Buffer-Template\&.java\fR to prevent it from being processed\&. The \f3javadoc\fR command only processes source files with names, when stripped of the \f3\&.java\fR suffix, that are valid class names\&.
.SH GENERATED\ FILES
By default, the \f3javadoc\fR command uses a standard doclet that generates HTML-formatted documentation\&. The standard doclet generates basic content, cross-reference, and support pages described here\&. Each HTML page corresponds to a separate file\&. The \f3javadoc\fR command generates two types of files\&. The first type is named after classes and interfaces\&. The second type contain hyphens (such as package-summary\&.html) to prevent conflicts with the first type of file\&.
.SS BASIC\ CONTENT\ PAGES
.TP 0.2i
\(bu
One class or interface page (classname\&.html) for each class or interface being documented\&.
.TP 0.2i
\(bu
One package page (package-summary\&.html) for each package being documented\&. The \f3javadoc\fR command includes any HTML text provided in a file with the name package\&.html or package-info\&.java in the package directory of the source tree\&.
.TP 0.2i
\(bu
One overview page (overview-summary\&.html) for the entire set of packages\&. The overview page is the front page of the generated document\&. The \f3javadoc\fR command includes any HTML text provided in a file specified by the \f3-overview\fR option\&. The Overview page is created only when you pass two or more package names into the \f3javadoc\fR command\&. See HTML Frames and Options\&.
.SS CROSS-REFERENCE\ PAGES
.TP 0.2i
\(bu
One class hierarchy page for the entire set of packages (overview-tree\&.html)\&. To view the hierarchy page, click \fIOverview\fR in the navigation bar and click \fITree\fR\&.
.TP 0.2i
\(bu
One class hierarchy page for each package (package-tree\&.html) To view the hierarchy page, go to a particular package, class, or interface page, and click \fITree\fR to display the hierarchy for that package\&.
.TP 0.2i
\(bu
One use page for each package (package-use\&.html) and a separate use page for each class and interface (class-use/classname\&.html)\&. The use page describes what packages, classes, methods, constructors and fields use any part of the specified class, interface, or package\&. For example, given a class or interface A, its use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A\&. To view the use page, go to the package, class, or interface and click the \fIUse\fR link in the navigation bar\&.
.TP 0.2i
\(bu
A deprecated API page (deprecated-list\&.html) that lists all deprecated APIs and their suggested replacements\&. Avoid deprecated APIs because they can be removed in future implementations\&.
.TP 0.2i
\(bu
A constant field values page (constant-values\&.html) for the values of static fields\&.
.TP 0.2i
\(bu
A serialized form page (serialized-form\&.html) that provides information about serializable and externalizable classes with field and method descriptions\&. The information on this page is of interest to reimplementors, and not to developers who want to use the API\&. To access the serialized form page, go to any serialized class and click \fISerialized Form\fR in the See Also section of the class comment\&. The standard doclet generates a serialized form page that lists any class (public or non-public) that implements Serializable with its \f3readObject\fR and \f3writeObject\fR methods, the fields that are serialized, and the documentation comments from the \f3@serial\fR, \f3@serialField\fR, and \f3@serialData\fR tags\&. Public serializable classes can be excluded by marking them (or their package) with \f3@serial\fR exclude, and package-private serializable classes can be included by marking them (or their package) with an \f3@serial\fR include\&. As of Release 1\&.4, you can generate the complete serialized form for public and private classes by running the \f3javadoc\fR command without specifying the \f3-private\fR option\&. See Options\&.
.TP 0.2i
\(bu
An index page (\f3index-*\&.html\fR) of all class, interface, constructor, field and method names, in alphabetical order\&. The index page is internationalized for Unicode and can be generated as a single file or as a separate file for each starting character (such as A\(enZ for English)\&.
.SS SUPPORT\ PAGES
.TP 0.2i
\(bu
A help page (help-doc\&.html) that describes the navigation bar and the previous pages\&. Use \f3-helpfile\fR to override the default help file with your own custom help file\&.
.TP 0.2i
\(bu
One index\&.html file that creates the HTML frames for display\&. Load this file to display the front page with frames\&. The index\&.html file contains no text content\&.
.TP 0.2i
\(bu
Several frame files (\f3*-frame\&.html\fR) that contains lists of packages, classes, and interfaces\&. The frame files display the HTML frames\&.
.TP 0.2i
\(bu
A package list file (package-list) that is used by the \f3-link\fR and \f3-linkoffline\fR options\&. The package list file is a text file that is not reachable through links\&.
.TP 0.2i
\(bu
A style sheet file (stylesheet\&.css) that controls a limited amount of color, font family, font size, font style, and positioning information on the generated pages\&.
.TP 0.2i
\(bu
A doc-files directory that holds image, example, source code, or other files that you want copied to the destination directory\&. These files are not processed by the \f3javadoc\fR command\&. This directory is not processed unless it exists in the source tree\&.
.PP
See Options\&.
.SS HTML\ FRAMES
The \f3javadoc\fR command generates the minimum number of frames (two or three) necessary based on the values passed to the command\&. It omits the list of packages when you pass a single package name or source files that belong to a single package as an argument to the \f3javadoc\fR command\&. Instead, the \f3javadoc\fR command creates one frame in the left-hand column that displays the list of classes\&. When you pass two or more package names, the \f3javadoc\fR command creates a third frame that lists all packages and an overview page (overview-summary\&.html)\&. To bypass frames, click the \fINo Frames\fR link or enter the page set from the overview-summary\&.html page\&.
.SS GENERATED\ FILE\ STRUCTURE
The generated class and interface files are organized in the same directory hierarchy that Java source files and class files are organized\&. This structure is one directory per subpackage\&.
.PP
For example, the document generated for the \f3java\&.applet\&.Applet\fR class would be located at java/applet/Applet\&.html\&.
.PP
The file structure for the \f3java\&.applet\fR package follows, assuming that the destination directory is named \f3apidocs\fR\&. All files that contain the word \fIframe\fR appear in the upper-left or lower-left frames, as noted\&. All other HTML files appear in the right-hand frame\&.
.PP
Directories are bold\&. The asterisks (*) indicate the files and directories that are omitted when the arguments to the \f3javadoc\fR command are source file names rather than package names\&. When arguments are source file names, an empty package list is created\&. The doc-files directory is not created in the destination unless it exists in the source tree\&. See Generated Files\&.
.TP 0.2i
\(bu
\fIapidocs\fR: Top-level directory
.RS
.TP 0.2i
\(bu
index\&.html: Initial Page that sets up HTML frames
.TP 0.2i
\(bu
*overview-summary\&.html: Package list with summaries
.TP 0.2i
\(bu
overview-tree\&.html: Class hierarchy for all packages
.TP 0.2i
\(bu
deprecated-list\&.html: Deprecated APIs for all packages
.TP 0.2i
\(bu
constant-values\&.html: Static field values for all packages
.TP 0.2i
\(bu
serialized-form\&.html: Serialized forms for all packages
.TP 0.2i
\(bu
*overview-frame\&.html: All packages for display in upper-left frame
.TP 0.2i
\(bu
allclasses-frame\&.html: All classes for display in lower-left frame
.TP 0.2i
\(bu
help-doc\&.html: Help about Javadoc page organization
.TP 0.2i
\(bu
index-all\&.html: Default index created without \f3-splitindex\fR option
.TP 0.2i
\(bu
\fIindex-files\fR: Directory created with \f3-splitindex\fR option
.RS
.TP 0.2i
\(bu
index-<number>\&.html: Index files created with \f3-splitindex\fR option
.RE
.TP 0.2i
\(bu
package-list: Package names for resolving external references
.TP 0.2i
\(bu
stylesheet\&.css: Defines fonts, colors, positions, and so on
.RE
.TP 0.2i
\(bu
\fIjava\fR: Package directory
.RS
.TP 0.2i
\(bu
\fIapplet\fR: Subpackage directory
.RS
.TP 0.2i
\(bu
Applet\&.html: \f3Applet\fR class page
.TP 0.2i
\(bu
AppletContext\&.html: \f3AppletContext\fR interface
.TP 0.2i
\(bu
AppletStub\&.html: \f3AppletStub\fR interface
.TP 0.2i
\(bu
AudioClip\&.html: \f3AudioClip\fR interface
.TP 0.2i
\(bu
package-summary\&.html: Classes with summaries
.TP 0.2i
\(bu
package-frame\&.html: Package classes for display in lower-left frame
.TP 0.2i
\(bu
package-tree\&.html: Class hierarchy for this package
.TP 0.2i
\(bu
package-use\&.html: Where this package is used
.TP 0.2i
\(bu
\fIdoc-files\fR: Image and example files directory
.TP 0.2i
\(bu
\fIclass-use\fR: Image and examples file location
- Applet\&.html: Uses of the Applet class
- AppletContext\&.html: Uses of the \f3AppletContext\fR interface
- AppletStub\&.html: Uses of the \f3AppletStub\fR interface
- AudioClip\&.html: Uses of the \f3AudioClip\fR interface
.RE
.RE
.TP 0.2i
\(bu
\fIsrc-html\fR: Source code directory
.RS
.TP 0.2i
\(bu
\fIjava\fR: Package directory
.RS
.TP 0.2i
\(bu
\fIapplet\fR: Subpackage directory
- Applet\&.html: Applet source code
- AppletContext\&.html: \f3AppletContext\fR source code
- AppletStub\&.html: \f3AppletStub\fR source code
- AudioClip\&.html: \f3AudioClip\fR source code
.RE
.RE
.SS GENERATED\ API\ DECLARATIONS
The \f3javadoc\fR command generates a declaration at the start of each class, interface, field, constructor, and method description for that API item\&. For example, the declaration for the \f3Boolean\fR class is:
.sp
.nf
\f3public final class Boolean\fP
.fi
.nf
\f3extends Object\fP
.fi
.nf
\f3implements Serializable\fP
.fi
.nf
\f3\fR
.fi
.sp
The declaration for the \f3Boolean\&.valueOf\fR method is:
.sp
.nf
\f3public static Boolean valueOf(String s)\fP
.fi
.nf
\f3\fR
.fi
.sp
The \f3javadoc\fR command can include the modifiers \f3public\fR, \f3protected\fR, \f3private\fR, \f3abstract\fR, \f3final\fR, \f3static\fR, \f3transient\fR, and \f3volatile\fR, but not \f3synchronized\fR or \f3native\fR\&. The \f3synchronized\fR and \f3native\fR modifiers are considered implementation detail and not part of the API specification\&.
.PP
Rather than relying on the keyword \f3synchronized\fR, APIs should document their concurrency semantics in the main description of the comment\&. For example, a description might be: A single enumeration cannot be used by multiple threads concurrently\&. The document should not describe how to achieve these semantics\&. As another example, while the \f3Hashtable\fR option should be thread-safe, there is no reason to specify that it is achieved by synchronizing all of its exported methods\&. It is better to reserve the right to synchronize internally at the bucket level for higher concurrency\&.
.SH DOCUMENTATION\ COMMENTS
This section describes source code comments and comment inheritance\&.
.SS SOURCE\ CODE\ COMMENTS
You can include documentation comments in the source code, ahead of declarations for any class, interface, method, constructor, or field\&. You can also create documentation comments for each package and another one for the overview, though their syntax is slightly different\&. A documentation comment consists of the characters between \f3/**\fR and \f3*/\fR that end it\&. Leading asterisks are allowed on each line and are described further in the following section\&. The text in a comment can continue onto multiple lines\&.
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * This is the typical format of a simple documentation comment\fP
.fi
.nf
\f3 * that spans two lines\&.\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3\fR
.fi
.sp
To save space you can put a comment on one line:
.sp
.nf
\f3/** This comment takes up only one line\&. */\fP
.fi
.nf
\f3\fR
.fi
.sp
.PP
Placement of Comments
Documentation comments are recognized only when placed immediately before class, interface, constructor, method, or field declarations\&. Documentation comments placed in the body of a method are ignored\&. The \f3javadoc\fR command recognizes only one documentation comment per declaration statement\&. See Where Tags Can Be Used\&.
.PP
A common mistake is to put an \f3import\fR statement between the class comment and the class declaration\&. Do not put an \f3import\fR statement at this location because the \f3javadoc\fR command ignores the class comment\&.
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * This is the class comment for the class Whatever\&.\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3import com\&.example; // MISTAKE \- Important not to put import statement here\fP
.fi
.nf
\f3\fR
.fi
.nf
\f3public class Whatever{ }\fP
.fi
.nf
\f3\fR
.fi
.sp
.PP
Parts of Comments
A documentation comment has a main description followed by a tag section\&. The main description begins after the starting delimiter \f3/**\fR and continues until the tag section\&. The tag section starts with the first block tag, which is defined by the first \f3@\fR character that begins a line (ignoring leading asterisks, white space, and leading separator \f3/**\fR)\&. It is possible to have a comment with only a tag section and no main description\&. The main description cannot continue after the tag section begins\&. The argument to a tag can span multiple lines\&. There can be any number of tags, and some types of tags can be repeated while others cannot\&. For example, this \f3@see\fR tag starts the tag section:
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * This sentence holds the main description for this documentation comment\&.\fP
.fi
.nf
\f3 * @see java\&.lang\&.Object\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3\fR
.fi
.sp
.PP
Block and inline Tags
A tag is a special keyword within a documentation comment that the \f3javadoc\fR command processes\&. There are two kinds of tags: block tags, which appear as an \f3@tag\fR tag (also known as standalone tags), and inline tags, which appear within braces, as an \f3{@tag}\fR tag\&. To be interpreted, a block tag must appear at the beginning of a line, ignoring leading asterisks, white space, and the separator (\f3/**\fR)\&. This means you can use the \f3@\fR character elsewhere in the text and it will not be interpreted as the start of a tag\&. If you want to start a line with the \f3@\fR character and not have it be interpreted, then use the HTML entity \f3@\fR\&. Each block tag has associated text, which includes any text following the tag up to, but not including, either the next tag, or the end of the documentation comment\&. This associated text can span multiple lines\&. An inline tag is allowed and interpreted anywhere that text is allowed\&. The following example contains the \f3@deprecated\fR block tag and the \f3{@link}\fR inline tag\&. See Javadoc Tags\&.
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * @deprecated As of JDK 1\&.1, replaced by {@link #setBounds(int,int,int,int)}\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3\fR
.fi
.sp
.PP
Write Comments in HTML
The text must be written in HTML with HTML entities and HTML tags\&. You can use whichever version of HTML your browser supports\&. The standard doclet generates HTML 3\&.2-compliant code elsewhere (outside of the documentation comments) with the inclusion of cascading style sheets and frames\&. HTML 4\&.0 is preferred for generated files because of the frame sets\&.
.PP
For example, entities for the less than symbol (<) and the greater than symbol (>) should be written as \f3<\fR and \f3>\fR\&. Similarly, the ampersand (&) should be written as \f3&\fR\&. The bold HTML tag \f3\fR is shown in the following example\&.
.sp
.nf
\f3/**\fP
.fi
.nf
\f3 * This is a <b>doc comment\&.\fP
.fi
.nf
\f3 * @see java\&.lang\&.Object\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3\fR
.fi
.sp
.PP
Leading Asterisks
When the \f3javadoc\fR command parses a documentation comment, leading asterisks (*) on each line are discarded, and blanks and tabs that precede the initial asterisks (*) are also discarded\&. If you omit the leading asterisk on a line, then the leading white space is no longer removed so that you can paste code examples directly into a documentation comment inside a \f3<PRE>\fR tag with its indentation preserved\&. Spaces are interpreted by browsers more uniformly than tabs\&. Indentation is relative to the left margin (rather than the separator \f3/**\fR or \f3
\fR tag)\&.
.PP
First Sentence
The first sentence of each documentation comment should be a summary sentence that contains a concise but complete description of the declared entity\&. This sentence ends at the first period that is followed by a blank, tab, or line terminator, or at the first block tag\&. The \f3javadoc\fR command copies this first sentence to the member summary at the top of the HTML page\&.
.PP
Multiple-Field Declarations
The Java platform lets you declare multiple fields in a single statement, but this statement can have only one documentation comment that is copied for all fields\&. If you want individual documentation comments for each field, then declare each field in a separate statement\&. For example, the following documentation comment does not make sense written as a single declaration and would be better handled as two declarations:
.sp
.nf
\f3/** \fP
.fi
.nf
\f3 * The horizontal and vertical distances of point (x,y)\fP
.fi
.nf
\f3 */\fP
.fi
.nf
\f3public int x, y; // Avoid this \fP
.fi
.nf
\f3\fR
.fi
.sp
The \f3javadoc\fR command generates the following documentation from the previous code:
.sp
.nf
\f3public int x\fP
.fi
.nf
\f3\fR
.fi
.sp
The horizontal and vertical distances of point (x, y)\&.
.sp
.nf
\f3public int y\fP
.fi
.nf
\f3\fR
.fi
.sp
The horizontal and vertical distances of point (x, y)\&.
.PP
Use of Header Tags
When writing documentation comments for members, it is best not to use HTML heading tags such as \f3<H1>\fR and \f3
\fR, because the \f3javadoc\fR command creates an entire structured document, and these structural tags might interfere with the formatting of the generated document\&. However, you can use these headings in class and package comments to provide your own structure\&.
.SS METHOD\ COMMENT\ INHERITANCE
The \f3javadoc\fR command allows method comment inheritance in classes and interfaces to fill in missing text or to explicitly inherit method comments\&. Constructors, fields, and nested classes do not inherit documentation comments\&.
.PP
\fINote:\fR The source file for an inherited method must be on the path specified by the \f3-sourcepath\fR option for the documentation comment to be available to copy\&. Neither the class nor its package needs to be passed in on the command line\&. This contrasts with Release 1\&.3\&.\fIn\fR and earlier releases, where the class had to be a documented class\&.
.PP
Fill in Missing Text
When a main description, or \f3@return\fR, \f3@param\fR, or \f3@throws\fR tag is missing from a method comment, the \f3javadoc\fR command copies the corresponding main description or tag comment from the method it overrides or implements (if any)\&. See Method Comment Inheritance\&.
.PP
When an \f3@param\fR tag for a particular parameter is missing, the comment for that parameter is copied from the method further up the inheritance hierarchy\&. When an \f3@throws\fR tag for a particular exception is missing, the \f3@throws\fR tag is copied only when that exception is declared\&.
.PP
This behavior contrasts with Release 1\&.3 and earlier, where the presence of any main description or tag would prevent all comments from being inherited\&.
.PP
See Javadoc Tags and Options\&.
.PP
Explicit Inheritance
Insert the \f3{@inheritDoc}\fR inline tag in a method main description or \f3@return\fR, \f3@param\fR, or \f3@throws\fR tag comment\&. The corresponding inherited main description or tag comment is copied into that spot\&.
.SS CLASS\ AND\ INTERFACE\ INHERITANCE
Comment inheritance occurs in all possible cases of inheritance from classes and interfaces:
.TP 0.2i
\(bu
When a method in a class overrides a method in a superclass
.TP 0.2i
\(bu
When a method in an interface overrides a method in a superinterface
.TP 0.2i
\(bu
When a method in a class implements a method in an interface
.PP
In the first two cases, the \f3javadoc\fR command generates the subheading \fIOverrides\fR in the documentation for the overriding method\&. A link to the method being overridden is included, whether or not the comment is inherited\&.
.PP
In the third case, when a method in a specified class implements a method in an interface, the \f3javadoc\fR command generates the subheading \fISpecified by\fR in the documentation for the overriding method\&. A link to the method being implemented is included, whether or not the comment is inherited\&.
.SS METHOD\ COMMENTS\ ALGORITHM
If a method does not have a documentation comment, or has an \f3{@inheritDoc}\fR tag, then the \f3javadoc\fR command uses the following algorithm to search for an applicable comment\&. The algorithm is designed to find the most specific applicable documentation comment, and to give preference to interfaces over superclasses:
.TP 0.4i
1\&.
Look in each directly implemented (or extended) interface in the order they appear following the word \f3implements\fR (or \f3extends\fR) in the method declaration\&. Use the first documentation comment found for this method\&.
.TP 0.4i
2\&.
If Step 1 failed to find a documentation comment, then recursively apply this entire algorithm to each directly implemented (or extended) interface in the same order they were examined in Step 1\&.
.TP 0.4i
3\&.
When Step 2 fails to find a documentation comment and this is a class other than the \f3Object\fR class, but not an interface:
.RS
.TP 0.4i
1\&.
If the superclass has a documentation comment for this method, then use it\&.
.TP 0.4i
2\&.
If Step 3a failed to find a documentation comment, then recursively apply this entire algorithm to the superclass\&.
.RE
.SH JAVADOC\ TAGS
The \f3javadoc\fR command parses special tags when they are embedded within a Java documentation comment\&. The \f3javadoc\fR tags let you autogenerate a complete, well-formatted API from your source code\&. The tags start with an at sign (\f3@\fR) and are case-sensitive\&. They must be typed with the uppercase and lowercase letters as shown\&. A tag must start at the beginning of a line (after any leading spaces and an optional asterisk), or it is treated as text\&. By convention, tags with the same name are grouped together\&. For example, put all \f3@see\fR tags together\&. For more information, see Where Tags Can Be Used\&.
.PP
Tags have the following types:
.TP 0.2i
\(bu
Bock tags: Place block tags only in the tag section that follows the description\&. Block tags have the form: \fI@tag\fR\&.
.TP 0.2i
\(bu
Inline tags: Place inline tags anywhere in the main description or in the comments for block tags\&. Inline tags are enclosed within braces: \fI{@tag}\fR\&.
.PP
For custom tags, see -tag tagname:Xaoptcmf:"taghead"\&. See also Where Tags Can Be Used\&.
.SS TAG\ DESCRIPTIONS
.TP
@author \fIname-text\fR
Introduced in JDK 1\&.0
Adds an Author entry with the specified name text to the generated documents when the \f3-author\fR option is used\&. A documentation comment can contain multiple \f3@author\fR tags\&. You can specify one name per \f3@author\fR tag or multiple names per tag\&. In the former case, the \f3javadoc\fR command inserts a comma (,) and space between names\&. In the latter case, the entire text is copied to the generated document without being parsed\&. Therefore, you can use multiple names per line if you want a localized name separator other than a comma\&. See @author in How to Write Doc Comments for the Javadoc Tool at http://www\&.oracle\&.com/technetwork/java/javase/documentation/index-137868\&.html#@author
.TP
{@code \fItext\fR}
Introduced in JDK 1\&.5
Equivalent to \f3<code>{@literal}\fR\&.
Displays text in code font without interpreting the text as HTML markup or nested Javadoc tags\&. This enables you to use regular angle brackets (< and >) instead of the HTML entities (\f3<\fR and \f3>\fR) in documentation comments, such as in parameter types (\f3
Other Java examples (source code examples)
Here is a short list of links related to this Java javadoc.1 source code file: