14. System Properties
Contents:
Java programs cannot read environment variables the way that native programs can. The reason is that environment variables are platform dependent. Similar mechanisms exist, however, that allow applications to read the value of a named resource. These resource values allow customization of an application's behavior based on site-specific parameters, such as the type of host, or based on user preferences. These named resource values are specified for applications in the "system properties" list. Applications can read these "system properties" with the System.getProperty() method, or can read the entire list of properties with System.getProperties(). System.getProperty() returns the property value as a string. Applications can also read properties in parsed form using methods that are based on System.getProperty(), such as Font.getFont(), Color.getColor(), Integer.getInteger(), and Boolean.getBoolean(). 14.1 Standard System PropertiesWhen the Java interpreter starts, it inserts a number of standard properties into the system properties list. These properties, and the meaning of their values, are listed in Table 14.1. The table also specifies whether untrusted applets are allowed (at least by default) to read the value of these properties. For reasons of security, untrusted code is only allowed to read the values of properties to which it has explicitly been granted access. (Untrusted applets are not allowed to set the value of system properties, nor are they allowed to call System.getProperties() to obtain the entire list of properties.)
|
|