2009年1月18日星期日

System里有那些属性

从没有细看过system的参数信息,随手几行代码打出来看看:
Properties prop = System.getProperties();
Iterator it = prop.keySet().iterator();
String key;
String value;
while(it.hasNext()) {
key = (String)it.next();
value = (String)prop.get(key);
System.out.println(key+": "+value);
}
大多数参数基本不需要我们关心,只有几个需要瞅几眼:
java.version 版本信息
sun.boot.class.path vm启动时装载的我们称之为标准的API(库、jar包)
java.ext.dirs vm启动时附加加载的jar,用户也可以丢进该目录(不推荐这么做),一般应用有自己的class load,如tomcat有全局的class load(tomcat下的lib)以及每个应用也有自己的class load(web-app下的lib)。
user.home 用户的OS主目录。
java.class.version 就是编译后的class文件包含编译器的版本信息,有时1.4编译后跑在1.5上,或相反,可能会抛出这种兼容性异常。

java.runtime.name: Java(TM) SE Runtime Environment
sun.boot.library.path: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/i386
java.vm.version: 10.0-b23
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: unknown
java.vm.specification.name: Java Virtual Machine Specification
user.dir: /work/shamrock-ws/eclipse-ws/java-test
java.runtime.version: 1.6.0_07-b06
java.awt.graphicsenv: sun.awt.X11GraphicsEnvironment
java.endorsed.dirs: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/endorsed
os.arch: i386
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.07/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/../lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/i386/client::/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/i386::/usr/lib/mozilla/:/usr/lib/mozilla/:/usr/java/packages/lib/i386:/lib:/usr/lib
java.specification.name: Java Platform API Specification
java.class.version: 50.0
sun.management.compiler: HotSpot Client Compiler
os.version: 2.6.24-16-generic
user.home: /home/abc
user.timezone:
java.awt.printerjob: sun.print.PSPrinterJob
file.encoding: UTF-8
java.specification.version: 1.6
java.class.path: /work/shamrock-ws/eclipse-ws/java-test/bin
user.name: abc
java.vm.specification.version: 1.0
java.home: /usr/lib/jvm/java-6-sun-1.6.0.07/jre
sun.arch.data.model: 32
user.language: zh
java.specification.vendor: Sun Microsystems Inc.
java.vm.info: mixed mode, sharing
java.version: 1.6.0_07
java.ext.dirs: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/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: gnome
sun.cpu.isalist:

没有评论: