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);
}
Example won't work in modern Java since a reserved word enum is being used as a variable name.
Simple solution: Rename enum to e and the example is still working.
java.util.Properties sysProperties = System.getProperties();
sysProperties.list(System.out);
Just found this and wanted to share, sorry for my bad english.
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());
}
}
}
(String)props.get(propName);
doesn't work as expected: as of java 1.4 it should be
(String)props.getProperty(propName);
I can't believe you're not playing with me--that was so heflpul.
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."