Javadoc

From Wikipedia, the free encyclopedia

Javadoc is a computer software tool from Sun Microsystems for generating API documentation into HTML format from Java source code.

Javadoc is the industry standard for documenting Java classes. Most IDEs will automatically generate Javadoc HTML.

Javadoc also provides an API for creating doclets and taglets, which allows you to analyze the structure of a Java application. This is how JDiff can generate reports of what changed between two versions of an API.

Contents

To document all the classes in a folder, run the following from the command line (or place it in a batch file and run that). Depending on your installation directory, you may have to tweak this example, but it will create a directory with documentation of all your classes:

"C:\Program Files\Java\jdk1.6.0\bin\javadoc" -d doc *.java

By default, only public members are shown. For deeper visibility, use any of the following switches:

  • -protected
  • -package
  • -private

Developers use certain commenting styles and Javadoc tags when documenting source code. A Java block comment starting with /** will begin a Javadoc comment block which will be included in the generated HTML. A Javadoc tag begins with an "@" (at sign). Some tags are provided in the following table.

Tag Description
@author Developer name
@deprecated Marks a method as deprecated. Some IDEs will issue a compilation warning if the method is called.
@exception Documents an exception thrown by a method — also see @throws.
@param Defines a method parameter. Required for each parameter.
@return Documents the return value. This tag should not be used for constructors or methods defined with a void return type.
@see Documents an association to another method or class.
@since Documents when a method was added to a class.
@throws Documents an exception thrown by a method. A synonym for @exception introduced in Javadoc 1.2.
@version Provides the version number of a class or method.

An example of using Javadoc to document a method follows. Notice that spacing and quantity of characters in this example are as conventions state.

/**
 * Validates a chess move.
 * 
 * @param theFromFile File of piece being moved
 * @param theFromRank Rank of piece being moved
 * @return            true if a valid chess move or false if invalid
 * @author            John Doe
 */
 boolean isValidMove(int theFromFile, int theFromRank, int theToFile, int theToRank)
 {
     ...  
 }

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.