Aqua Phoenix
     >>  Lectures >>  Java 5  
 

Navigator
   
 
       
   

5.7 JavaDoc

JavaDoc is a tool that creates a full HTML web site from Java comments. Similar to the Java API, this web site contains an index of all methods, classes, and packages. JavaDoc specifically uses the comments before a method prototype. For this to function properly, the following conventions must be met. Example:

* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
*


* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param  url  an absolute URL giving the base location of the image
* @param  name the location of the image, relative to the url argument
* @return      the image at the specified URL
* @see        Image
*/
public Image getImage(URL url, String name) {

  try {
    return getImage(new URL(url, name));
  } catch (MalformedURLException e) {
    return null;
  }
}

Such comments should be included for every method and class.

To generate the JavaDoc web site, the following command is used:

javadoc SomeClass.java
or

javadoc *.java
There are many options that can be used to customize the web site. Type in javadoc without arguments to see a list.