获取所有系统属性

Java中,系统属性是通过System.getProperty(String key)来获取的,也可以通过System.setProperty(String key, Object value)来设置。

对于获取系统属性的代码是非常简单的,主要是把所有系统默认存储的属性打印出来,以后就可以直接查了,不用每次都去Google

 

代码:

       Properties props = System.getProperties();

       for(Entry<Object, Object> entry : props.entrySet()) {

           Object key = entry.getKey();

           Object value = entry.getValue();

           System.out.println(key + " - " + value);

       }

运行结果:

java.runtime.name - Java(TM) SE Runtime Environment

sun.boot.library.path - C:\Program Files\Java\jre6\bin

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 -

java.vm.specification.name - Java Virtual Machine Specification

user.dir -

java.runtime.version - 1.6.0_21-b07

java.awt.graphicsenv - sun.awt.Win32GraphicsEnvironment

java.endorsed.dirs - C:\Program Files\Java\jre6\lib\endorsed

os.arch - x86

java.io.tmpdir - C:\Users\Levin\AppData\Local\Temp\

line.separator -

 

java.vm.specification.vendor - Sun Microsystems Inc.

user.variant -

os.name - Windows 7

sun.jnu.encoding - GBK

java.library.path - C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;E:\Program Files\Ant\apache-ant-1.8.1\bin;C:\Program Files\Rational\common

java.specification.name - Java Platform API Specification

java.class.version - 50.0

sun.management.compiler - HotSpot Client Compiler

os.version - 6.1

user.home - C:\Users\Levin

user.timezone -

java.awt.printerjob - sun.awt.windows.WPrinterJob

file.encoding - GBK

java.specification.version - 1.6

java.class.path - E:\CodeRepository\Java\TomcatReading\MyClassLoader\bin;E:\CodeRepository\Java\TomcatReading\DomainInterfaces\bin;E:\CodeRepository\Java\ExtClassPath;E:\CodeRepository\Java\TomcatReading\DomainLib\bin

user.name - Levin

java.vm.specification.version - 1.0

java.home - C:\Program Files\Java\jre6

sun.arch.data.model - 32

user.language - zh

java.specification.vendor - Sun Microsystems Inc.

awt.toolkit - sun.awt.windows.WToolkit

java.vm.info - mixed mode, sharing

java.version - 1.6.0_21

java.ext.dirs - C:\Program Files\Java\jre6\lib\ext;C:\Windows\Sun\Java\lib\ext

sun.boot.class.path - C:\Program Files\Java\jre6\lib\resources.jar;C:\Program Files\Java\jre6\lib\rt.jar;C:\Program Files\Java\jre6\lib\sunrsasign.jar;C:\Program Files\Java\jre6\lib\jsse.jar;C:\Program Files\Java\jre6\lib\jce.jar;C:\Program Files\Java\jre6\lib\charsets.jar;C:\Program Files\Java\jre6\classes

java.vendor - Sun Microsystems Inc.

file.separator - \

java.vendor.url.bug - http://java.sun.com/cgi-bin/bugreport.cgi

sun.io.unicode.encoding - UnicodeLittle

sun.cpu.endian - little

sun.desktop - windows

sun.cpu.isalist - pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

你可能感兴趣的:(java,C++,c,C#,sun)