Monday, October 7, 2013

Get system properties with System.getProperties()

The getProperties() method of java.lang.System class return a Properties object. With this Properties object, we can get all the keys in this property list by calling its propertyNames() method. Then gets the system property indicated by the specified key by calling its System.getProperty(String key)/or getProperty(String key) method of the Properties object.

Get system properties with System.getProperties()
Get system properties with System.getProperties()

package java_systemproperties;

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

 * @web
public class Java_SystemProperties {

    public static void main(String[] args) {
        Properties properties = System.getProperties();
        Enumeration<String> prop = 
                (Enumeration<String>) properties.propertyNames();
            String propName = prop.nextElement();
                    propName + " : " +

Related: Get info of running jvm, os and cpu - tested on Windows 10

1 comment: