Previous | Next | Trail Map | Essential Java Classes | Contents

Setting Program Attributes

Java programs run within an environment that contains system attributes: a host machine, a user, a current directory, and an operating system. A Java program also can set up its own configurable attributes, called program attributes. Program attributes allow the user to configure various startup options, preferred window size, and so on for the program. Sometimes the term preferences is used instead of program attributes.

System attributes are maintained by the System class and are covered later in System Properties. Java programs can set their own set of program attributes through three mechanisms: properties, command-line arguments, and applet parameters.

Setting Up and Using Properties

A property defines attributes on a persistent basis. That is, you use properties when attribute values need to persist between invocations of a program. This section shows you how to do this in your programs.

Command-Line Arguments

A command-line argument defines attributes for Java applications on a nonpersistent basis. You use command-line arguments to set one or more attributes for a single invocation of an application. This section shows how to accept and process command-line arguments in a Java program.

Applet Parameters

An applet parameter is similar to a command-line argument, except that it is 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(in the Writing Applets trail).


Previous | Next | Trail Map | Essential Java Classes | Contents