How Do I Document Packages in Java?

JavaPackagesJavadoc

Java Problem Overview


In the Java APIs I can see Javadoc comments for packages.

How/where do I place Javadoc comments to document a package?

Java Solutions


Solution 1 - Java

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

Solution 2 - Java

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

Solution 3 - Java

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjjnguyView Question on Stackoverflow
Solution 1 - JavaGareth DavisView Answer on Stackoverflow
Solution 2 - JavasleskeView Answer on Stackoverflow
Solution 3 - Javaoxbow_lakesView Answer on Stackoverflow