How do I list System properties?
Author: Deron Eriksson
Description: This Java tutorial shows how to list System properties.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1

The System Properties object is a set of key/value pairs that stores information about the current runtime environment. This information includes things such as the JavaSW version, Operating System version, user name, etc.

The ListSystemProperties class shows how to output the system properties to standard output. A Properties object is obtained via System.getProperties(), and the property keys (or 'names') are enumerated over, and the value is looked up for each key. The property key (name) and property value are displayed for each pair.

package test;

import java.util.Enumeration;
import java.util.Properties;

public class ListSystemProperties {
	public static void main(String[] args) {
		Properties systemProperties = System.getProperties();
		Enumeration enuProp = systemProperties.propertyNames();
		while (enuProp.hasMoreElements()) {
			String propertyName = (String) enuProp.nextElement();
			String propertyValue = systemProperties.getProperty(propertyName);
			System.out.println(propertyName + ": " + propertyValue);

The results of the execution of ListSystemProperties on my system are displayed below.

results.txt Java(TM) 2 Runtime Environment, Standard Edition
sun.boot.library.path: C:\jdk1.5.0_09\jre\bin
java.vm.version: 1.5.0_09-b03
java.vm.vendor: Sun Microsystems Inc.
path.separator: ; Java HotSpot(TM) Client VM
file.encoding.pkg: US
sun.os.patch.level: Service Pack 2 Java Virtual Machine Specification
user.dir: C:\projects\workspace\testing
java.runtime.version: 1.5.0_09-b03
java.awt.graphicsenv: sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs: C:\jdk1.5.0_09\jre\lib\endorsed
os.arch: x86 C:\DOCUME~1\Deron\LOCALS~1\Temp\

java.vm.specification.vendor: Sun Microsystems Inc.
user.variant: Windows XP
sun.jnu.encoding: Cp1252
java.library.path: C:\jdk1.5.0_09\jre\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\jdk1.5.0_09\bin;C:\maven-2.0.4\bin;C:\jadnt158; Java Platform API Specification
java.class.version: 49.0 HotSpot Client Compiler
os.version: 5.1
user.home: C:\Documents and Settings\Deron
file.encoding: Cp1252
java.specification.version: 1.5 Deron
java.class.path: C:\projects\workspace\testing\bin
java.vm.specification.version: 1.0 32
java.home: C:\jdk1.5.0_09\jre
java.specification.vendor: Sun Microsystems Inc.
user.language: en
awt.toolkit: mixed mode
java.version: 1.5.0_09
java.ext.dirs: C:\jdk1.5.0_09\jre\lib\ext
sun.boot.class.path: C:\jdk1.5.0_09\jre\lib\rt.jar;C:\jdk1.5.0_09\jre\lib\i18n.jar;C:\jdk1.5.0_09\jre\lib\sunrsasign.jar;C:\jdk1.5.0_09\jre\lib\jsse.jar;C:\jdk1.5.0_09\jre\lib\jce.jar;C:\jdk1.5.0_09\jre\lib\charsets.jar;C:\jdk1.5.0_09\jre\classes
java.vendor: Sun Microsystems Inc.
file.separator: \
sun.cpu.endian: little UnicodeLittle
sun.desktop: windows
sun.cpu.isalist: pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86