In the Java APIs I can see Javadoc comments for packages.
How/where do I place Javadoc comments to document a package?
From the main menu, select Tools | Generate JavaDoc. In the dialog that opens, select a scope — a set of files or directories for which you want to generate the reference, and set the output directory where the generated documentation will be placed.
To create a package, you choose a name for the package (naming conventions are discussed in the next section) and put a package statement with that name at the top of every source file that contains the types (classes, interfaces, enumerations, and annotation types) that you want to include in the package.
Javadoc (originally cased JavaDoc) is a documentation generator created by Sun Microsystems for the Java language (now owned by Oracle Corporation) for generating API documentation in HTML format from Java source code.
A package is a single folder (directory) containing a group of related classes and interfaces. A package declaration, if used, must be the first thing in the file, and describes the folder in which it occurs. For example, the declaration. package org.
Since Java 1.5 you can also provide a package-info.java, which contains a regular Javadoc comment (no HTML). The latter is preferred, as it gives you some extra features (notably package annotations). Show activity on this post.
Choose a package name according to the naming convention. Write the package name at the top of every source file (classes, interface, enumeration, and annotations). Remember that there must be only one package statement in each source file. We follow the naming convention rules to name a package.
Package class A java package is a group of similar types of classes, interfaces and sub-packages. Package in java can be categorized in two form, built-in package and user-defined package. There are many built-in packages such as java, lang, awt, javax, swing, net, io, util, sql etc.
// To import the whole package The import statement is optional in Java. If you want to use class/interface from a certain package, you can also use its fully qualified name, which includes its full package hierarchy. Here is an example to import a package using the import statement.
As of 1.5 you can define a package-info.java
file and provide a standard javadoc style comment for a package:
com/foo/package-info.java:
/**
* com.foo is a group of bar utils for operating on foo things.
*/
package com.foo;
//rest of the file is empty
Language specification for packages
Up to and including Java 1.4, you had to provide a HTML file package.html, as described in the other answers.
Since Java 1.5 you can also provide a package-info.java
, which contains a regular Javadoc comment (no HTML). The latter is preferred, as it gives you some extra features (notably package annotations).
Details: Sun's docs for javadoc
With a package.html
file at the package level (i.e. in the directory for that package). This should be a fully-formed HTML
file, with the <html>
tag defined in it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With