how-to

Others

How to list system properties

In java.lang.System class are saved system properties. Data are saved internally in java.util.Hashtable class.

For this section you need to use:

import java.util.*;

This sample code go throught Hashtable class instance and read all its keys and values.

/* -- get system properties */
Hashtable h = System.getProperties();

/* -- get keys */

Enumeration e = h.keys();

/* -- go throught keys + read key value */

while( e.hasMoreElements() ) {

  /* key */
  Object k = e.nextElement();

  /* read key */
  System.out.print( k );
  /* read key value */
  System.out.println( "\t\t" + h.get( k ) );

}

The output could be (in depending on installed JDK and current system, here aligned into table):

Property Value
java.runtime.nameJava(TM) SE Runtime Environment
sun.boot.library.pathC:\Program Files\Java\jdk1.7.0_07\jre\bin
java.vm.version23.3-b01
java.vm.vendorOracle Corporation
java.vendor.urlhttp://java.oracle.com/
path.separator;
java.vm.nameJava HotSpot(TM) Client VM
file.encoding.pkgsun.io
user.countryCZ
user.script
sun.java.launcherSUN_STANDARD
sun.os.patch.levelService Pack 3
java.vm.specification.nameJava Virtual Machine Specification
user.dirD:\java\projects_netbeans\Test10_text
java.runtime.version1.7.0_07-b11
java.awt.graphicsenvsun.awt.Win32GraphicsEnvironment
java.endorsed.dirsC:\Program Files\Java\jdk1.7.0_07\jre\lib\endorsed
os.archx86
java.io.tmpdirC:\DOCUME~1\pirkl\LOCALS~1\Temp\
line.separator
java.vm.specification.vendorOracle Corporation
user.variant
os.nameWindows XP
sun.jnu.encodingCp1250
java.library.pathC:\Program Files\Java\jdk1.7.0_07\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\PHP\;C:\Program Files\PHP\ext;.
sun.awt.enableExtraMouseButtonstrue
java.specification.nameJava Platform API Specification
java.class.version51.0
sun.management.compilerHotSpot Client Compiler
os.version5.1
user.homeC:\Documents and Settings\pirkl
user.timezone
java.awt.printerjobsun.awt.windows.WPrinterJob
file.encodingUTF-8
java.specification.version1.7
java.class.pathD:\java\lib\ojdbc14.jar;D:\java\projects_netbeans\Test10_text\build\classes
user.namepirkl
java.vm.specification.version1.7
sun.java.commandMain
java.homeC:\Program Files\Java\jdk1.7.0_07\jre
sun.arch.data.model32
user.languagecs
java.specification.vendorOracle Corporation
awt.toolkitsun.awt.windows.WToolkit
java.vm.infomixed mode, sharing
java.version1.7.0_07
java.ext.dirsC:\Program Files\Java\jdk1.7.0_07\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
sun.boot.class.pathC:\Program Files\Java\jdk1.7.0_07\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_07\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_07\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.7.0_07\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_07\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_07\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_07\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_07\jre\classes
java.vendorOracle Corporation
file.separator\
java.vendor.url.bughttp://bugreport.sun.com/bugreport/
sun.io.unicode.encodingUnicodeLittle
sun.cpu.endianlittle
sun.desktopwindows
sun.cpu.isalistpentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86