How to Use Javadoc in DrJava

In general, Javadoc HTML files are most useful when they are generated in large batches, since the HTML files for each of the related classes can link to each other. For this reason, DrJava's "Javadoc All Documents" command looks for all source files in the folders and subfolders of the open documents and includes them all in the documentation, saving the files in a "doc" folder nearby. (This folder will be placed either in the current folder or the top-level folder of the current package.) On the other hand, it is occasionally useful to view the Javadoc HTML for a single class, to quickly get a feel for its structure. Therefore, DrJava also provides a "Preview Javadoc for Current Document" command that only generates Javadoc for the current open document without saving it to a permanent location. (This command saves the file in a temporary location that will be automatically deleted when you quit DrJava.) If either of these commands finds errors in the source files, they will report them in a tab like compiler errors.

Viewing Javadoc. When either of the "Javadoc All Documents" or "Preview Javadoc for Current Document" commands complete successfully (or find only warnings and no errors), DrJava displays the resulting HTML files in a new window. For Windows and Mac OS X users, these files will be displayed in the system's default web browser. On other platforms, the files will be displayed in a simple viewer, unless the "Web Browser" option has been configured in the "Resource Locations" section of the Preferences (see Configuring DrJava).

Configuring Javadoc. You can configure many aspects of how Javadoc files are generated. Most prominent is the ability to hide fields and methods below a particular access level (eg. public or protected). By default, no private fields or methods are shown. Other options include specifying a URL to link to the Java library API (which defaults to Oracle's own website), specifying a default destination directory for all Javadoc files, and specifying any custom parameters to pass to the Javadoc tool itself. Finally, for programs with many nested packages (folders), DrJava provides an option to always generate Javadoc for all packages in the program, rather than just the sub-packages of the open documents.