Print all System Properties java

Print all System Properties java

If you are trying to find some system properties value and not able to get it then you could use below sample code which will prints all System properties:

package com.javahonk.sysproperties;

import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

public class PrintSystemProperties {

    public static void main(String[] args) {

    Properties properties = System.getProperties();
    Set<Entry<Object, Object>> set = properties.entrySet();

    for (Entry<Object, Object> entry : set) {           
        System.out.println("Key: "+ entry.getKey()
                +"  Value: "+entry.getValue());     
    }   

    }
}

 

Output was big showing only first 10 line from console:

Print all System Properties java

 

Below are list of important system properties use frequently by the user:

Details Key
Operating system name “os.name”
User work directory “user.dir”
Path separator character in java.class.path “path.separator”
OS version “os.version”
User home “user.home”
User account name “user.name”
Character that separates components of a file path.  “/” on UNIX and “\” on Windows “file.separator”
Path which uses to find directories and JAR archives contains class files. “java.class.path”
Installation directory JRE “java.home”
JRE vendor name “java.vendor”
JRE vendor URL “java.vendor.url”
JRE version number “java.version”
Sequence use operating system to separate lines in text files “line.separator”
OS architecture “os.arch”

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *