// 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 old fashioned, non-generified Hashtables, suporting the old fashioned, non-generified Enumeration interface.
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.
When you are debugging an Applet, you can see the system properties by typing s on the Applet console. You can dump them in an app with:
// debugging dump System properties on the console System.getProperties().list( System.out );
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 |
Typical Value | Description | accessible
in unsigned Applet? |
|---|---|---|---|
| awt.toolkit | sun.awt.windows.WToolkit | name of AWT implementation | |
| awt.useSystemAAFontSettings | what sort of anti-aliasing to use. | ||
| browser | Opera.plugin | name of browser | |
| browser.version | 9.64 | version of browser | |
| file.encoding | Cp1252 | default encoding e.g. Cp1252 | |
| file.separator | \ | File separator (e.g.,\ for Windows, / for Unix) | |
| java.class.path | Java classpath | ||
| java.class.version | 50.0 | Java class file format version number | |
| java.ext.dirs | C:\Program Files\Java\jre6\lib\ext;C:\Windows\Sun\Java\lib\ext | Path of extension directory or directories | |
| java.home | C:\Program Files\java\jre6 | Java installation directory | |
| java.io.tmpdir | C:\Users\roedy\AppData\Local\Temp\ | Default temp directory | |
| java.library.path | F:\Program Files\Opera;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;F:\Program Files\jet6.5-beta5\bin;E:\Program Files\Java\jdk1.6.0_16\bin;E:\env;E:\sys\;F:\Program Files\jpsoft\TCMD11;F:\Program Files\vslick\win;F:\Program Files\apache-ant-1.7.1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;E:\com\mindprod\reorg;F:\Program Files\TortoiseSVN\bin;F:\program files\asm;F:\Program Files\Microsoft Visual Studio 9.0\VC\bin | 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 | 1.6.0_16-b03 | Java Runtime version. | |
| java.specification.name | Java Platform API Specification | Java Runtime Environment specification name | |
| java.specification.vendor | Sun Microsystems Inc. | Java Runtime Environment specification vendor | |
| java.specification.version | 1.6 | Java Runtime Environment specification version | |
| java.vendor | Sun Microsystems Inc. | JRE vendor | |
| java.vendor.url | http://java.sun.com/ | JRE vendor URL | |
| java.version | JRE version number . | ||
| java.vm.name | Java HotSpot(TM) Client VM | Java Virtual Machine implementation name | |
| java.vm.specification.name | Java Virtual Machine Specification | Java Virtual Machine specification name | |
| java.vm.specification.vendor | Sun Microsystems Inc. | Java Virtual Machine specification vendor | |
| java.vm.specification.version | 1.0 | Java Virtual Machine specification version | |
| java.vm.vendor | Sun Microsystems Inc. | Java Virtual Machine implementation vendor | |
| java.vm.version | 11.3-b02 | Java Virtual Machine implementation version | |
| line.separator | [hex chars: 0x0d 0x0a i.e. CrLf, \r\n] | Line separator, e.g. \r\n on Windows, \r on Mac, \n on Unix | |
| os.arch | x86 | Operating system architecture, e.g. x86 | |
| os.arch.data.model | 32 | 32 or 64 bit addressing | |
| os.name | Windows Vista | 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 | C:\Program Files\java\jre6\bin | where DLLs are. | |
| sun.io.unicode.encoding | UnicodeLittle | endian, UnicodeLittle or UnicodeBig | |
| swing.aatext | true turns on anti-aliasing for smooth fonts in JDK 1.5+ | ||
| user.country | CA | two-letter country code, upper case. | |
| user.dir | C:\Windows\system32 | User’s current working directory | |
| user.home | C:\Users\roedy | User home directory | |
| user.language | two-letter language code, lower case. | ||
| user.name | en | 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 even more properties I did not list, especially if you run in a browser or under Jet.
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.
| os.name |
|---|
| AIX |
| Digital Unix |
| FreeBSD |
| HP UX |
| Irix |
| Linux |
| Mac OS |
| Mac OS X |
| MPE/iX |
| Netware 4.11 |
| OS/2 |
| Solaris |
| Windows 2000 |
| Windows 95 |
| Windows 98 |
| Windows NT |
| Windows Vista |
| Windows XP |
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.
| 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 |
| You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | |
| http://mindprod.com/jgloss/properties.html | J:\mindprod\jgloss\properties.html | |
![]() | ||
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.191.101] | |
| Feedback | You are visitor number 174,856. | |