2008年6月1日星期日

列出 JVM/JRE 当前的所有系统属性

使用一行代码即可得知:


public static void main(String[] args) {
System.getProperties().list(System.out);
}


以下是我的输出:


-- listing properties --
java.runtime.name=Java(TM) SE Runtime Environment
sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.06/jre/...
java.vm.version=10.0-b22
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=:
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
file.encoding.pkg=sun.io
user.country=CN
sun.java.launcher=SUN_STANDARD
sun.os.patch.level=unknown
java.vm.specification.name=Java Virtual Machine Specification
user.dir=/home/****/code/NetBeansProjects/Main
java.runtime.version=1.6.0_06-b02
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment
java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.06/jre/...
os.arch=amd64
java.io.tmpdir=/tmp
line.separator=

java.vm.specification.vendor=Sun Microsystems Inc.
os.name=Linux
sun.jnu.encoding=UTF-8
java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.06/jre/...
java.specification.name=Java Platform API Specification
java.class.version=50.0
sun.management.compiler=HotSpot 64-Bit Server Compiler
os.version=2.6.24-17-generic
user.home=/home/****
user.timezone=
java.awt.printerjob=sun.print.PSPrinterJob
file.encoding=UTF-8
java.specification.version=1.6
user.name=****
java.class.path=/home/****/code/NetBeansProjects/Mai...
java.vm.specification.version=1.0
sun.arch.data.model=64
java.home=/usr/lib/jvm/java-6-sun-1.6.0.06/jre
java.specification.vendor=Sun Microsystems Inc.
user.language=zh
java.vm.info=mixed mode
java.version=1.6.0_06
java.ext.dirs=/usr/lib/jvm/java-6-sun-1.6.0.06/jre/...
sun.boot.class.path=/usr/lib/jvm/java-6-sun-1.6.0.06/jre/...
java.vendor=Sun Microsystems Inc.
file.separator=/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.desktop=gnome
sun.cpu.isalist=



请注意,在此配置下,如果想读写日期格式:dd-MMM-YYYY (01-Jun-2008),
是会出错的,如果在不修改源码的情况下,需要修改系统属性:


java -Duser.language=en ...