通过System.getProperty()可以获取很多值,究竟能获得哪些值,今天写了个小程序看了下(为了看起来更清晰,每个properties后面加了横线):

package test;

import java.util.Properties;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        Properties properties = System.getProperties();
        Set<Object>  keySet = properties.keySet();
        for(Object p:keySet){
            System.out.println(p+":"+System.getProperty((String)p));
System.out.println("----------------------------------------------------------------------"); } } }

运行结果如下:

java.runtime.name:Java(TM) SE Runtime Environment
----------------------------------------------------------------------
sun.boot.library.path:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\bin
----------------------------------------------------------------------
java.vm.version:24.45-b08
----------------------------------------------------------------------
java.vm.vendor:Oracle Corporation
----------------------------------------------------------------------
java.vendor.url:http://java.oracle.com/
----------------------------------------------------------------------
path.separator:;
----------------------------------------------------------------------
java.vm.name:Java HotSpot(TM) 64-Bit Server VM
----------------------------------------------------------------------
file.encoding.pkg:sun.io
----------------------------------------------------------------------
user.country:CN
----------------------------------------------------------------------
user.script:
----------------------------------------------------------------------
sun.java.launcher:SUN_STANDARD
----------------------------------------------------------------------
sun.os.patch.level:
----------------------------------------------------------------------
java.vm.specification.name:Java Virtual Machine Specification
----------------------------------------------------------------------
user.dir:E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform
----------------------------------------------------------------------
java.runtime.version:1.7.0_45-b18
----------------------------------------------------------------------
java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment
----------------------------------------------------------------------
java.endorsed.dirs:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\endorsed
----------------------------------------------------------------------
os.arch:amd64
----------------------------------------------------------------------
java.io.tmpdir:C:\Users\andong\AppData\Local\Temp\
----------------------------------------------------------------------
line.separator:

----------------------------------------------------------------------
java.vm.specification.vendor:Oracle Corporation
----------------------------------------------------------------------
user.variant:
----------------------------------------------------------------------
os.name:Windows 8
----------------------------------------------------------------------
sun.jnu.encoding:GBK
----------------------------------------------------------------------
java.library.path:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;E:\UltraEdit;E:\TortoiseSVN\bin;E:\WinSCP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;E:\OpenSSH for Windows\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;E:\SSH Secure Shell;C:\Users\andong\AppData\Local\Microsoft\WindowsApps;;.
----------------------------------------------------------------------
java.specification.name:Java Platform API Specification
----------------------------------------------------------------------
java.class.version:51.0
----------------------------------------------------------------------
sun.management.compiler:HotSpot 64-Bit Tiered Compilers
----------------------------------------------------------------------
os.version:6.2
----------------------------------------------------------------------
user.home:C:\Users\andong
----------------------------------------------------------------------
user.timezone:
----------------------------------------------------------------------
java.awt.printerjob:sun.awt.windows.WPrinterJob
----------------------------------------------------------------------
file.encoding:UTF-8
----------------------------------------------------------------------
java.specification.version:1.7
----------------------------------------------------------------------
java.class.path:E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\classes;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\bean-validator.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.annotation.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.ejb.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.enterprise.deploy.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.jms.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.management.j2ee.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.persistence.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.resource.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.security.auth.message.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.security.jacc.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.servlet.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.servlet.jsp.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\javax.transaction.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\jaxb-api-osgi.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\jsr311-api.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\mail.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\webservices-api-osgi.jar;E:\MyEclipse Professional 2014\plugins\com.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640\data\libraryset\EE_6\weld-osgi-bundle.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\aopalliance.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\apache-ant-zip.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\bcprov-jdk14-138.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-codec-1.4.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-collections-3.2.1.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-dbcp-1.4.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-discovery-0.2.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-fileupload-1.3.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-io-1.4.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-lang-2.6.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-logging-1.1.1.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-net-3.0.1.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\commons-pool-1.6.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\curvesapi-1.03.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\dom4j-1.6.1.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\httpclient-4.3.1.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\httpcore-4.3.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\jackson-all-1.9.11.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\javacsv.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\jsch-0.1.51.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\jstl-1.2.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\log4j-1.2.16.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.22.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.aop-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.asm-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.beans-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.context-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.context.support-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.core-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.expression-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.jdbc-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.orm-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.transaction-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.web-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\org.springframework.web.servlet-3.1.2.RELEASE.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\poi-3.14-20160307.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\poi-ooxml-3.14-20160307.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\poi-ooxml-schemas-3.14-20160307.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\quartz-1.6.4.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\rt.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\xmlbeans-2.6.0.jar;E:\MyEclipse Professional 2014\MyEclipse\sinasoftworkspace\ReconciliationPlatform\WebRoot\WEB-INF\lib\zip4j-1.3.2.jar
----------------------------------------------------------------------
user.name:andong
----------------------------------------------------------------------
java.vm.specification.version:1.7
----------------------------------------------------------------------
sun.java.command:test.Test
----------------------------------------------------------------------
java.home:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre
----------------------------------------------------------------------
sun.arch.data.model:64
----------------------------------------------------------------------
user.language:zh
----------------------------------------------------------------------
java.specification.vendor:Oracle Corporation
----------------------------------------------------------------------
awt.toolkit:sun.awt.windows.WToolkit
----------------------------------------------------------------------
java.vm.info:mixed mode
----------------------------------------------------------------------
java.version:1.7.0_45
----------------------------------------------------------------------
java.ext.dirs:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
----------------------------------------------------------------------
sun.boot.class.path:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\resources.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\rt.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\sunrsasign.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\jsse.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\jce.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\charsets.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\jfr.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\classes
----------------------------------------------------------------------
java.vendor:Oracle Corporation
----------------------------------------------------------------------
file.separator:\
----------------------------------------------------------------------
java.vendor.url.bug:http://bugreport.sun.com/bugreport/
----------------------------------------------------------------------
sun.io.unicode.encoding:UnicodeLittle
----------------------------------------------------------------------
sun.cpu.endian:little
----------------------------------------------------------------------
sun.desktop:windows
----------------------------------------------------------------------
sun.cpu.isalist:amd64
----------------------------------------------------------------------

 

上面只是在main方法中测试的,没有涉及服务器,后来又在服务器启动时测试了一下(使用的是tomcat6),打印如下:

java.runtime.name:Java(TM) SE Runtime Environment
----------------------------------------------------------------------
sun.boot.library.path:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\bin
----------------------------------------------------------------------
java.vm.version:24.45-b08
----------------------------------------------------------------------
shared.loader:
----------------------------------------------------------------------
java.vm.vendor:Oracle Corporation
----------------------------------------------------------------------
java.vendor.url:http://java.oracle.com/
----------------------------------------------------------------------
path.separator:;
----------------------------------------------------------------------
tomcat.util.buf.StringCache.byte.enabled:true
----------------------------------------------------------------------
java.vm.name:Java HotSpot(TM) 64-Bit Server VM
----------------------------------------------------------------------
file.encoding.pkg:sun.io
----------------------------------------------------------------------
user.country:CN
----------------------------------------------------------------------
user.script:
----------------------------------------------------------------------
sun.java.launcher:SUN_STANDARD
----------------------------------------------------------------------
sun.os.patch.level:
----------------------------------------------------------------------
java.vm.specification.name:Java Virtual Machine Specification
----------------------------------------------------------------------
user.dir:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43\bin
----------------------------------------------------------------------
java.runtime.version:1.7.0_45-b18
----------------------------------------------------------------------
java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment
----------------------------------------------------------------------
java.endorsed.dirs:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43/common/endorsed
----------------------------------------------------------------------
os.arch:amd64
----------------------------------------------------------------------
java.io.tmpdir:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43\temp
----------------------------------------------------------------------
line.separator:

----------------------------------------------------------------------
java.vm.specification.vendor:Oracle Corporation
----------------------------------------------------------------------
java.naming.factory.url.pkgs:org.apache.naming
----------------------------------------------------------------------
user.variant:
----------------------------------------------------------------------
os.name:Windows 8
----------------------------------------------------------------------
sun.jnu.encoding:GBK
----------------------------------------------------------------------
java.library.path:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\bin;E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43\bin
----------------------------------------------------------------------
java.specification.name:Java Platform API Specification
----------------------------------------------------------------------
java.class.version:51.0
----------------------------------------------------------------------
sun.management.compiler:HotSpot 64-Bit Tiered Compilers
----------------------------------------------------------------------
sun.io.useCanonCaches:false
----------------------------------------------------------------------
os.version:6.2
----------------------------------------------------------------------
user.home:C:\Users\andong
----------------------------------------------------------------------
catalina.useNaming:true
----------------------------------------------------------------------
user.timezone:Asia/Shanghai
----------------------------------------------------------------------
java.awt.printerjob:sun.awt.windows.WPrinterJob
----------------------------------------------------------------------
file.encoding:GBK
----------------------------------------------------------------------
java.specification.version:1.7
----------------------------------------------------------------------
catalina.home:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43
----------------------------------------------------------------------
java.class.path:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43/bin/bootstrap.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45/lib/tools.jar
----------------------------------------------------------------------
user.name:andong
----------------------------------------------------------------------
java.naming.factory.initial:org.apache.naming.java.javaURLContextFactory
----------------------------------------------------------------------
package.definition:sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.,org.apache.tomcat.
----------------------------------------------------------------------
java.vm.specification.version:1.7
----------------------------------------------------------------------
sun.java.command:org.apache.catalina.startup.Bootstrap start
----------------------------------------------------------------------
java.home:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre
----------------------------------------------------------------------
sun.arch.data.model:64
----------------------------------------------------------------------
user.language:zh
----------------------------------------------------------------------
java.specification.vendor:Oracle Corporation
----------------------------------------------------------------------
awt.toolkit:sun.awt.windows.WToolkit
----------------------------------------------------------------------
java.vm.info:mixed mode
----------------------------------------------------------------------
java.version:1.7.0_45
----------------------------------------------------------------------
java.ext.dirs:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
----------------------------------------------------------------------
sun.boot.class.path:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\resources.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\rt.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\sunrsasign.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\jsse.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\jce.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\charsets.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\lib\jfr.jar;E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre\classes
----------------------------------------------------------------------
server.loader:
----------------------------------------------------------------------
java.vendor:Oracle Corporation
----------------------------------------------------------------------
catalina.base:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43
----------------------------------------------------------------------
file.separator:\
----------------------------------------------------------------------
java.vendor.url.bug:http://bugreport.sun.com/bugreport/
----------------------------------------------------------------------
common.loader:${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
----------------------------------------------------------------------
sun.io.unicode.encoding:UnicodeLittle
----------------------------------------------------------------------
sun.cpu.endian:little
----------------------------------------------------------------------
package.access:sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,org.apache.naming.resources.,org.apache.tomcat.,sun.beans.
----------------------------------------------------------------------
sun.desktop:windows
----------------------------------------------------------------------
sun.cpu.isalist:amd64
----------------------------------------------------------------------

 

通过对比,在tomcat中运行时的属性比在main方法中要多一些, 有些值也不太相同。

下表是API提供的properties属性键值和说明,和刚才打印出的相比也不太全:

相关值的描述
java.version Java 运行时环境版本
java.vendor Java 运行时环境供应商
java.vendor.url Java 供应商的 URL
java.home Java 安装目录
java.vm.specification.version Java 虚拟机规范版本
java.vm.specification.vendor Java 虚拟机规范供应商
java.vm.specification.name Java 虚拟机规范名称
java.vm.version Java 虚拟机实现版本
java.vm.vendor Java 虚拟机实现供应商
java.vm.name Java 虚拟机实现名称
java.specification.version Java 运行时环境规范版本
java.specification.vendor Java 运行时环境规范供应商
java.specification.name Java 运行时环境规范名称
java.class.version Java 类格式版本号
java.class.path Java 类路径
java.library.path 加载库时搜索的路径列表
java.io.tmpdir 默认的临时文件路径
java.compiler 要使用的 JIT 编译器的名称
java.ext.dirs 一个或多个扩展目录的路径
os.name 操作系统的名称
os.arch 操作系统的架构
os.version 操作系统的版本
file.separator 文件分隔符(在 UNIX 系统中是“/”)
path.separator 路径分隔符(在 UNIX 系统中是“:”)
line.separator 行分隔符(在 UNIX 系统中是“/n”)
user.name 用户的账户名称
user.home 用户的主目录
user.dir 用户的当前工作目录

 

而且从刚才打印的结果看,部分属性的值也并不准确。比如我的系统是windows 10,打印结果是os.name:Windows 8

针对上面main方法和tomcat中的运行结果,重点总结几个可能常用的属性:

  • 文件分隔符 file.separator:\
  • 路径分隔符 path.separator:;
  • 行分隔符 line.separator:\r\n
  • 用户当前工作目录 user.dir。需要注意的是在main方法中,指向了当前的项目路径,但是在tomcat中,指向了tomcat的bin目录
  • 操作系统名称 os.name。 不过该项并不准确
  • java运行时环境版本 java.version:1.7.0_45
  • Java 安装目录 java.home:E:\MyEclipse Professional 2014\binary\com.sun.java.jdk7.win32.x86_64_1.7.0.u45\jre 。该目录是java jre的目录
  • 用户的语言 user.language:zh
  • 用户名称(计算机名称) user.name:andong ,不过经过测试如果你用微软账户登陆,它这里拿到的还是原来的名字
  • 用户所在时区 user.timezone:Asia/Shanghai  不过main方法中并未打印时区
  • 还有tomcat下打印了catalina的相关信息:catalina.home:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43  
  • catalina.base:E:\apache-tomcat-6.0.43-windows-x86\apache-tomcat-6.0.43

 

这次的测试结果使用的是jdk1.7,tomcat6,windows10,linux下的情况并未测试