< Zurück | Inhalt | Weiter >

5.4.2 java Options

Just as the Java compiler, the runtime program, java, takes a number of com- mand-line options. Here are the most commonly used ones:

-classpath or -cp

Sets the runtime classpath. Overrides any value in the CLASSPATH

environment variable.

-Dproperty=value

Allows a system property to be set on the command line.

-jar

Specifies that the first nonoption command-line argument is not a Java class name, but the name of a JAR file. The JAR file must have a Main-Class: specification in its MANIFEST (see Section 5.11). The main() method of the class named by the JAR’s MANIFEST Main-Class: specification will be called as if that class had been named on the command line, rather than the JAR file. This is commonly used in shell scripts and batch files that accompany Java applications distributed in single

.jar files.

There are several other command-line options that are less commonly used. We will cover some of them in later chapters when their use will make more sense. Of course, full documentation on all options for this command is in the Sun Java SDK Development Tools documentation.


5.5 COMPLETE, UP-TO-DATE PROGRAM DOCUMENTATION MADE EASY


One of Java’s most useful features is javadoc, a command that (by default) produces comprehensive HTML program documentation directly from the program source. Since it works from the source, it can be automated, and you may be certain that the documentation is up-to-date. It takes much of the documentation burden off of programmers and permits new programmers to join a project and rapidly come up to speed because there is comprehensive documentation in a standard format. The javadoc tool produces HTML


documentation by default, but this is because it uses a doclet that produces HTML documentation. You can write your own doclet that produces whatever format you wish. Most find the HTML documentation so satisfactory that custom doclets are rare.

Javadoc can be a large topic, because it not only documents all classes, methods, and class variables, but can also use detailed text from specially for- matted comments in the source code. We will cover Javadoc comments only briefly here, but you will see examples in our project code throughout this book.