Properties : Java Glossary
home P words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
Properties
java.util.Properties is a platform-independent generalisation of the DOS SET environment, or the Windows *.INI files. In Java, even each object could have its own list of properties. A program can determine if an entry is missing in the property file and provide a default to using it its place. Even though property names typically have dots in them, there is no matching hierarchical structure like the NT registry, not even sections as with the Win 3.1 INI files. Properties are just glorified Hashtables that can be backed to to disk in human-readable format. You lookup by property name and get a value. Properties also can be used to store other sorts of key=value data on disk. (They will even work with key:value or key value pairs.)
Accessing Delphi Properties
Overriding Network Properties
Security And System Properties Default File and Console Encoding
os.name Learning More
User Properties Links
JavaBean Properties

Accessing

You can interrogate the run-time environment with code like this:
// get a system property
String vendor = System.getProperty( "java.vendor" );
System.out.println( vendor );
To discover the entire list of supported system properties and their current values you could use code like this:

Unfortunately that code produces a list in scrambled order. It won’t be either alphabetical or in the order of the original properties file, because underneath, Properties are just Hashtables.

The System properties are generated by a magic native method System.initProperties. There is no corresponding jar element or *.properties file on disk. file. You can temporarily add a System property with the -D option on the java.exe line. You can also use the technique to pass the value of a SET variable in as a system property. For Applets, there is a similar PARAM mechanism that generates a properties table.

Overriding Properties on the Command Line

If you have a property with a space in it quote the whole thing like this:

Security And System Properties

Using
System.getProperty( "java.version" );
is preferable to
System.getProperties().getProperty( "java.version" );
so you won’t trigger a security violation in an Applet in the process of getting one of the unrestricted properties. System.getProperties will always raise a security exception in an Applet (since it fetches both everything, both restricted and unrestricted properties) but System.getProperty may or may not, depending on which property you ask for.

Here is how you set a system property:

// turn on anti-aliasing for smooth fonts.
System.setProperty( "swing.aatext", "true" );
System
PropertyName
Description accessible
in unsigned
Applet?
awt.toolkit name of AWT implementation
aawt.useSystemAAFontSettings what sort of anti-aliasing to use.
browser name of browser (e.g. Opera.plugin)
browser.version version of browser (e.g. 8.02)
file.encoding default encoding e.g. Cp1252
file.separator File separator (e.g.,\ for Windows, / for Unix)
java.class.path Java classpath
java.class.version Java class file format version number, e.g. 49.0
java.ext.dirs Path of extension directory or directories
java.home Java installation directory, e.g.C:\Program Files\java\jre1.6.0_06
java.io.tmpdir Default temp directory
java.library.path List of paths to search when loading libraries.
Contains the exe path.
java.protocol.handler.pkgs package prefixes to search for custom protocol handler classes.
Packages separated by |.
java.runtime.version Java Runtime version. e.g. 1.6.0-beta2-b74
java.specification.name Java Runtime Environment specification name
java.specification.vendor Java Runtime Environment specification vendor
java.specification.version Java Runtime Environment specification version
java.vendor JRE vendor
java.vendor.url JRE vendor URL
java.version JRE version number, e.g. .
java.vm.name Java Virtual Machine implementation name
java.vm.specification.name Java Virtual Machine specification name
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.version Java Virtual Machine specification version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.version Java Virtual Machine implementation version
line.separator Line separator, e.g. \r\n on Windows, \r on Mac, \n on Unix
os.arch Operating system architecture, e.g. x86
os.name Operating system name, e.g. Windows 2000
path.separator Path separator (e.g., ; for Windows; : for Unix)
sun.boot.class.path Classpath with all of Sun and browser jars.
sun.boot.library.path e.g.C:\Program Files\java\jre1.6.0_06\bin
sun.io.unicode.encoding endian, little or big
swing.aatext true turns on anti-aliasing for smooth fonts in JDK 1.5+
user.country two-letter country code, upper case.
user.dir User’s current working directory
user.home User home directory
user.language two-letter language code, lower case.
user.name User account name.
user.timezone timezone name e.g. America/Los_Angeles for PST.
Discontinued in JDK 1.2+.
Use TimeZone. getDefault() instead.

The only way I know of to determine which properties are safe in unsigned Applets and which are restricted to applications and signed Applets is to write test Applet to fetch the properties and see which ones raise an Exception. I used an unsigned version of Wassup to create this table.

There are also system properties for proxies that you are not present when there are no proxies.

There are no system properties to tell you about the JDK.

There is no system property to tell you how many cpus there are. However, you can get it with Runtime.availableProcessors.

Sun’s Javadoc on the System Properties method : available:
You can also dynamically set the system properties with System. setProperty, but of course the Security Manager will be on your case if you do this in an unsigned Applet.

os.name

Here are the values Sun uses for the os.name property to identify various platforms:
os.name
AIX
Digital Unix
FreeBSD
HP UX
Irix
Linux
Mac OS
MPE/iX
Netware 4.11
OS/2
Solaris
Windows 2000
Windows 95
Windows 98
Windows NT
Windows XP

User Properties

In contrast to the natively generated system properties, ordinary user Properties are usually loaded into RAM in their entirety and indexed for rapid Hashtable access and are later saved to flat files on disk with the *.properties extension. Properties files on disk are similar to the old Windows 3.1 INI files, except they have no […] sections. They are text files encoded with ISO-8859-1 keyword=value pairs. You can get additional characters with \uxxxx escapes or with \t, \r, \n, or \f. Comments begin with #. Lines may be continued by ending them in a trailing \. To embed spaces in a properties file, you must code them as e.g. red\ fire\ engine not "red fire engine". Lines are terminated by a linefeed, not necessarily a CrLf as is common in Win95. Properties files have the form key=value where the key may not contain spaces. You can use _ (underscore) in key names to represent a space. Look at any *.properties files file to see an example. It will look something like this example
The key thing to understand is that, in RAM, Properties are just glorified Hashtables. The documentation, at first reading, makes them sound as if they are much more complicated than they really are. Unlike ordinary Hashtables, they can be backed up to flat files that look like a bit like *.INI files. These files are loaded as a whole into RAM Hashtables for searching. The files are never linearly searched on disk to look up keys. Searching is always done with the RAM-resident Hashtable. You could access a property in a sample.properties file like this:

Since Properties are Hashtables, they scramble the order of the elements. If you want to preserve order, and don’t need key lookup, you can parse the file yourself with a StreamTokenizer and put it in an array. See how com.mindprod.business.Misc.loadProprerties code used by Learn To Count loads its ordered list of languages and classes from a properties file. Learn to Count keeps its properties file in the jar file. It accesses the file with:

then later uses a StreamTokenizer to process it.

To create a new Properties file from scratch programmatically, remember that java.util.Properties is a subclass of java.util.Hashtable. Just create a new Properties object, add the elements to it as if it were a Hashtable and finally save it with Properties.store() or the JDK 1.2-deprecated Properties.save() in old Javas.

JavaBean Properties

Property has a second meaning. In JavaBeans, components have associated persistent objects. You can modify various fields in those objects to configure them. The accessible fields of a JavaBean are called properties. They are accessible via public get/set methods. There need not be an actual field, just the get/set methods that simulate one. These are a completely separate mechanism.

Delphi Properties

Property has a third meaning, the Delphi sense. A property is a get/set method that masquerades as an ordinary instance or public static field to the clients of the class. See my Bali proposal for adding such properties to Java.

Network Properties

There is a another set of properties you can access with java.security.Security. getProperty. Beware, unused properties will return null, not the default. Mainly they are used to configure proxies.
Important Networking Properties
Property Notes
networkaddress.cache.ttl time in seconds to cache a successful DNS lookup. Oddly the default is -1 to default forever. So if the DNS changes, Java will not never notice until you shutdown and restart.
networkaddress.cache.negative.ttl time in seconds to cache a unsuccessful DNS lookup. 0=never cache, -1=forever, 10=default.
http.proxyHost http proxy
http.proxyPort http proxy
ftp.proxyHost ftp proxy
ftp.proxyPort ftp proxy

Learning More

Sun’s Javadoc on the Properties class : available:
Sun’s JDK Technote Guide on Networking properties : available:
Sun’s Javadoc on the getProperties method : available:

CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.17] The information on this page is for non-military use only.
You are visitor number 109,395. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/properties.html J:\mindprod\jgloss\properties.html