Previous | Next | Trail Map | Writing Java Programs | Table of Contents


Setting Program Attributes

Your Java programs run within some environment. That is, the program runs in an environment where there's a user, a host machine, a current directory, and user preferences for window color, font, font size and other environmental attributes. In addition to these system (or runtime) attributes that describe the system environment for the program, your application may also set up certain, configurable, application-specific attributes. Application attributes are often called preferences and allow the user to configure various start up options, preferred window size, or whatever.

A program typically needs information about the system and application environment to make decisions about how to do something or what to do. Also, a program may wish to modify certain attributes itself or allow a user to change them. Thus a program needs to be able to read and write various system attributes and program-specific attributes. Java programs can manage these program attributes through three mechanisms: properties, application command line arguments, and applet parameters.

Properties

Use properties to define environmental attributes on a persistent basis. That is, use properties when their values need to persist between invocations of a program.

Application Command Line Arguments

In contrast to properties, you use command line arguments to set or modify properties on a non-persistent basis for Java applications. You use command line arguments to set one or more attributes for just one invocation of a program.

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 more information about applet parameters, see Defining and Using Applet Parameters(in the Writing Applets trail).


Note about terminology: The term properties is used synonymously with the term attributes because properties in your Java program represent a set of attributes. The term command line arguments is never a synonym to the attributes. You just use command line arguments to set or modify properties.


Previous | Next | Trail Map | Writing Java Programs | Table of Contents