13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.5 Complete, Up-to-Date Program Documentati<strong>on</strong> Made Easy123documentati<strong>on</strong> by default, but this is because it uses a doclet that producesHTML documentati<strong>on</strong>. You can write your own doclet that produces whateverformat you wish. Most find the HTML documentati<strong>on</strong> so satisfactory thatcustom doclets are rare.Javadoc can be a large topic, because it not <strong>on</strong>ly documents all classes,methods, and class variables, but can also use detailed text from specially formattedcomments in the source code. We will cover Javadoc comments <strong>on</strong>lybriefly here, but you will see examples in our project code throughout this book.5.5.1 Running javadocThe javadoc command has the following general form:javadoc [opti<strong>on</strong>s...] [package names...] [source filenames...][@optfile...]Opti<strong>on</strong>s are covered in the next secti<strong>on</strong>. You can specify the classes todocument in two ways. First, you can list <strong>on</strong>e or more Java packages <strong>on</strong> thecommand line. Source code for the named packages is searched for <strong>on</strong> thesource classpath (see Secti<strong>on</strong> 5.5.2). Wildcards are not permitted inpackage names.Sec<strong>on</strong>d, you may list as many Java source files as you like, and you mayuse wildcards in the names.As with the javac compiler above, the @optfile allows you to name a textfile whose lines are treated as arguments as if they had been typed <strong>on</strong> the commandline.Example 5.5 shows how to run javadoc <strong>on</strong> our small multiclass sample.In this case, we were in the “base directory” of the package when we ranthe command. In other words, net was a subdirectory of the current workingdirectory when we ran Javadoc. Javadoc uses the same default classpaths andenvir<strong>on</strong>ment variables as javac does, so by default “.” is <strong>on</strong> the path.Generally, specifying packages is the most c<strong>on</strong>venient way to document anumber of classes, since packages are how collecti<strong>on</strong>s of classes are generallymanaged in Java development.Figure 5.1 shows the main screen of the documentati<strong>on</strong> thus produced.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!