Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Document Packages in Java?

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

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

like image 851
jjnguy Avatar asked Mar 08 '09 22:03

jjnguy


People also ask

How do you create a Java document?

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.

How can packages be declared in Java?

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.

What is a documentation in Java?

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.

What are packages package declaration in Java?

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.

Is there a way to provide a package-info in Java?

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.

How do you name a package in Java?

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.

What are the types of packages in Java?

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.

How do you import the whole package in Java?

// 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.


3 Answers

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

like image 100
Gareth Davis Avatar answered Oct 09 '22 23:10

Gareth Davis


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

like image 25
sleske Avatar answered Oct 09 '22 21:10

sleske


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

like image 31
oxbow_lakes Avatar answered Oct 09 '22 21:10

oxbow_lakes