java.util.Properties is a platform-independent generalisation of the DOS (Disk Operating System) SET environment, or the Windows *.INI files. In Java, even each object could have its own list of properties. It stored command line (Windows) or Terminal (uBuntu) commands that can be use in java to get necessary informations about OS where our java application running, like information of OS temp dir path, java version, etc , example :

"java -version" command in cmdInstead of using following code :

private void runExec(){
String s = null;
try {
Process p = Runtime.getRuntime().exec("java -version");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}

} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}

it far more better to use System.getProperties(String stringProperties) like this :

private void javaProperties(){
    System.out.println(System.getProperty("java.runtime.version"));
    System.out.println(System.getProperty("java.runtime.name"));
    System.out.println(System.getProperty("java.vm.name"));
}

Both codes give you same info like command line picture above, but the second code is more easy to use. Now what you need is list or glossary of stringProperties parameter. By using code below you can see all of System.getProperties parameters and results :

private void showAllSystemGetPropertiesParam(){
    Properties systemProperties = System.getProperties();
    Enumeration enums = systemProperties.propertyNames();
    for (; enums.hasMoreElements();) {
        String key = (String) enums.nextElement();
        String value = systemProperties.getProperty(key);
        System.out.println(key + " = " + value);
    }
}

Here is parameters and results if code above compiled and running :

java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = C:\Program Files\Java\jdk1.6.0_14\jre\bin
java.vm.version = 14.0-b16
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
path.separator = ;
java.vm.name = Java HotSpot(TM) Client VM
file.encoding.pkg = sun.io
user.country = ID
sun.java.launcher = SUN_STANDARD
sun.os.patch.level = Service Pack 1
java.vm.specification.name = Java Virtual Machine Specification
user.dir = C:\Users\EtaYuy\Documents\NetBeansProjects\SystemProperties
java.runtime.version = 1.6.0_14-b08
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs = C:\Program Files\Java\jdk1.6.0_14\jre\lib\endorsed
os.arch = x86
java.io.tmpdir = C:\Users\EtaYuy\AppData\Local\Temp\
line.separator =

java.vm.specification.vendor = Sun Microsystems Inc.
user.variant =
os.name = Windows Vista
sun.jnu.encoding = Cp1252
java.library.path = C:\Program Files\Java\jdk1.6.0_14\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\CyberLink\Power2Go;C:\Program Files\TortoiseGit\bin;C:\Program Files\Java\jdk1.6.0_14\bin
java.specification.name = Java Platform API Specification
java.class.version = 50.0
sun.management.compiler = HotSpot Client Compiler
os.version = 6.0
user.home = C:\Users\EtaYuy
user.timezone =
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = UTF-8
java.specification.version = 1.6
user.name = EtaYuy
java.class.path = C:\Users\EtaYuy\Documents\NetBeansProjects\SystemProperties\build\classes;C:\Users\EtaYuy\Documents\NetBeansProjects\SystemProperties\src
java.vm.specification.version = 1.0
sun.arch.data.model = 32
java.home = C:\Program Files\Java\jdk1.6.0_14\jre
java.specification.vendor = Sun Microsystems Inc.
user.language = in
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode, sharing
java.version = 1.6.0_14
java.ext.dirs = C:\Program Files\Java\jdk1.6.0_14\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path = C:\Program Files\Java\jdk1.6.0_14\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_14\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_14\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_14\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_14\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_14\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_14\jre\classes
java.vendor = Sun Microsystems Inc.
file.separator = \
java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
sun.cpu.endian = little
sun.io.unicode.encoding = UnicodeLittle
sun.desktop = windows
sun.cpu.isalist = pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

Quite useful isn’t? Well I hope so. Thanks for reading🙂 .

For info about my newest post :