Javadoc

Javadoc is a tool for generating API documentation in HTML format from doc comments in source code. The purpose of the API is to provide information about code so other programmers can use it without needing a thorough knowledge of its inner workings. In order to produce the API, Javadoc requires comments in a particular format. The official rules for commenting are listed in a 17 page document online, so we will only be requiring a subset of this format, though it is encouraged that you read and employ the full documentation format.

Commenting Format

Running Javadoc

Javadoc is included in Java 2 SDK and does not need a separate download or installation.

Javadoc was created to provide information of source code to multiple programmers. For any major project involving multiple programmers, code is usually written with packages, classes, interfaces and methods. As such, Javadoc can only be applied to packages, classes and interfaces inside those packages, and methods inside of those (although exceptions are possible, they require some extra work).

When running Javadoc, run it from the command line with the following arguments:

   javadoc -sourcepath code-path -d destination package-names

A description of each of the command line options is below:

For instance, if you wanted Javadoc to generate HTML files for a package AST, whose source files are located in C:\cs212\AST, and output the files to C:\cs212\out, your command line arguments would be as follows:

   javadoc -sourcepath C:\cs212 -d C:\cs212\out AST

Sample Javadoc output

Running Javadoc produces a number of files. The starting point you want to open first is called index.html, and the rest of the files are accesible as links. For example, Javadoc was run on the classes Foo and Loo which are part of the package narf. The API it produced can be viewed here.

Additional Information