Table of Contents |
Your Java programs run within some environment where there's a host machine, a current directory, user preferences for window color, font, font size, and other attributes. In addition to these system (or runtime) attributes, your program can set up certain configurable, program-specific attributes. Program attributes are often called preferences and allow the user to configure various startup options, preferred window size, and so on.A program might need information about the system environment to make decisions about how to do something. Also, a program might modify certain attributes itself or allow a user to change them. As a result, a program needs to be able to read and sometimes modify both system attributes and program attributes. Java programs can manage program attributes through three mechanisms: properties, application command-line arguments, and applet parameters.
Setting Up and Using Properties
Properties define environmental attributes on a persistent basis. That is, use properties when attribute values need to persist between invocations of a program.Command-Line Arguments
Command-line arguments define attributes for Java applications on a non-persistent basis. You use command-line arguments to set one or more attributes for a single invocation of an application.
Note: The Java language supports command-line arguments. For some systems such as Mac OS, however, command-line arguments don't make sense. To avoid platform dependencies in your Java applications, avoid the use of command-line arguments. Use properties instead.
Applet Parameters
Applet parameters are similar to command-line arguments but are used with applets, not applications. Use applet parameters to set one or more attributes for a single invocation of an applet. For information about applet parameters, see Defining and Using Applet Parameters.
Table of Contents |