Listing All System Properties

// Get all system properties
Properties props = System.getProperties();

// Enumerate all system properties
Enumeration enum = props.propertyNames();
for (; enum.hasMoreElements(); ) {
    // Get property name
    String propName = (String)enum.nextElement();

    // Get property value
    String propValue = (String)props.get(propName);
}

Comments

1 Apr 2010 - 10:35am by Anonymous (not verified)

Example won't work in modern Java since a reserved word enum is being used as a variable name.

21 Apr 2010 - 6:09am by Anonymous (not verified)

Simple solution: Rename enum to e and the example is still working.

9 Jun 2010 - 12:21pm by Daos (not verified)

java.util.Properties sysProperties = System.getProperties();
sysProperties.list(System.out);

Just found this and wanted to share, sorry for my bad english.

27 Jan 2011 - 3:34pm by Anonymous G (not verified)

This works with JRE6:

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

public class PropertiesFinder {

public static void main(String args[]) {
// Get all system properties
Properties props = System.getProperties();
{
// Enumerate all system properties
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();)
System.out.println(e.nextElement());
}
}
}

12 Jul 2011 - 3:06am by Elder (not verified)

(String)props.get(propName);
doesn't work as expected: as of java 1.4 it should be
(String)props.getProperty(propName);

27 Aug 2011 - 9:19am by Winter (not verified)

I can't believe you're not playing with me--that was so heflpul.

13 Oct 2011 - 6:02pm by belstaff outlet (not verified)

Toothpaste sister often chop and change, with a soft toothbrush elder brother, all dating hair and his

brother to fall in love with electric toothbrush.
Today a new neighbor, toothpaste sister: "wow, how tall you have a type oh ~ you call what name ~ we

date."
The new neighbor also said: "no. I'm a comb."

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.