How to add package level comments in Javadoc?

Anil Kumar.C picture Anil Kumar.C · Sep 6, 2010 · Viewed 38.3k times · Source

I am using CheckStyle, FindBugs, and PMD to validate my Java code. I have fixed almost all the bugs caught by these tools.

I am not able to understand how to write "package comment" which is a bug caught by checkstyle. I have gone through the documentation of CheckStyle, but I don't understand it.

Could someone help me in writing a package level comment in Java?

Answer

Michael Borgwardt picture Michael Borgwardt · Sep 6, 2010

Package-level javadoc comments are placed in a file named package-info.java inside the package directory. It contains the comment and a package declaration:

/**
 * Provides the classes necessary to create an applet and the classes an applet uses 
 * to communicate with its applet context. 
 * <p>
 * The applet framework involves two entities: 
 * the applet and the applet context. An applet is an embeddable window (see the 
 * {@link java.awt.Panel} class) with a few extra methods that the applet context 
 * can use to initialize, start, and stop the applet.
 *
 * @since 1.0
 * @see java.awt
 */
package java.lang.applet;

This is documented here: Package Comment Files