public static void main(String[] args) {
Properties properties = System.getProperties() ; for(Map.Entry<?, ?> entry : properties.entrySet()){ System.out.println( entry.getKey() + "-->" + entry.getValue() ); } System.out.println( System.getProperty("##########################") ); Map<String , String> map = System.getenv() ; for(Map.Entry<?, ?> entry : map.entrySet()){ System.out.println( entry.getKey() + "-->" + entry.getValue() ) ; } }
系統輸出這樣的結果:
java.runtime.name-->Java(TM) SE Runtime Environment
sun.boot.library.path-->E:softJAVAjdk1.6.0_21jrebin
java.vm.version-->17.0-b17
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
sun.java.launcher-->SUN_STANDARD
user.country-->CN
sun.os.patch.level-->Service Pack 3
java.vm.specification.name-->Java Virtual Machine Specification
user.dir-->F:httpclient
java.runtime.version-->1.6.0_21-b07
java.awt.graphicsenv-->sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs-->E:softJAVAjdk1.6.0_21jrelibendorsed
os.arch-->x86
java.io.tmpdir-->C:DOCUME~1ADMINI~1LOCALS~1Temp
line.separator-->
java.vm.specification.vendor-->Sun Microsystems Inc.
user.variant-->
os.name-->Windows XP
sun.jnu.encoding-->GBK
java.library.path-->E:softJAVAjdk1.6.0_21bin;.;C:WINDOWSSunJavabin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;E:softJAVAjdk1.6.0_21bin;E:softapache-maven-3.0.4bin;
java.specification.name-->Java Platform API Specification
java.class.version-->50.0
sun.management.compiler-->HotSpot Client Compiler
os.version-->5.1
user.home-->C:Documents and SettingsAdministrator
user.timezone-->