通过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 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrein ---------------------------------------------------------------------- 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 2014MyEclipsesinasoftworkspaceReconciliationPlatform ---------------------------------------------------------------------- java.runtime.version:1.7.0_45-b18 ---------------------------------------------------------------------- java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment ---------------------------------------------------------------------- java.endorsed.dirs:E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibendorsed ---------------------------------------------------------------------- os.arch:amd64 ---------------------------------------------------------------------- java.io.tmpdir:C:UsersandongAppDataLocalTemp ---------------------------------------------------------------------- line.separator: ---------------------------------------------------------------------- java.vm.specification.vendor:Oracle Corporation ---------------------------------------------------------------------- user.variant: ---------------------------------------------------------------------- os.name:Windows 8 ---------------------------------------------------------------------- sun.jnu.encoding:GBK ---------------------------------------------------------------------- java.library.path:E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45in;C:WINDOWSSunJavain;C:WINDOWSsystem32;C:WINDOWS;C:ProgramDataOracleJavajavapath;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:Program Files (x86)NVIDIA CorporationPhysXCommon;E:UltraEdit;E:TortoiseSVNin;E:WinSCP;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;E:OpenSSH for Windowsin;C:Program FilesMySQLMySQL Utilities 1.6;E:SSH Secure Shell;C:UsersandongAppDataLocalMicrosoftWindowsApps;;. ---------------------------------------------------------------------- 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:Usersandong ---------------------------------------------------------------------- user.timezone: ---------------------------------------------------------------------- java.awt.printerjob:sun.awt.windows.WPrinterJob ---------------------------------------------------------------------- file.encoding:UTF-8 ---------------------------------------------------------------------- java.specification.version:1.7 ---------------------------------------------------------------------- java.class.path:E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFclasses;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6ean-validator.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.annotation.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.ejb.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.enterprise.deploy.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.jms.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.management.j2ee.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.persistence.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.resource.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.security.auth.message.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.security.jacc.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.servlet.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.servlet.jsp.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6javax.transaction.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6jaxb-api-osgi.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6jsr311-api.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6mail.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6webservices-api-osgi.jar;E:MyEclipse Professional 2014pluginscom.genuitec.eclipse.j2eedt.core_11.5.0.me201311281640datalibrarysetEE_6weld-osgi-bundle.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibaopalliance.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibapache-ant-zip.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcprov-jdk14-138.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-codec-1.4.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-collections-3.2.1.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-dbcp-1.4.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-discovery-0.2.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-fileupload-1.3.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-io-1.4.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-lang-2.6.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-logging-1.1.1.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-net-3.0.1.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcommons-pool-1.6.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibcurvesapi-1.03.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibdom4j-1.6.1.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibhttpclient-4.3.1.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibhttpcore-4.3.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibjackson-all-1.9.11.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibjavacsv.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibjsch-0.1.51.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibjstl-1.2.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliblog4j-1.2.16.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibmysql-connector-java-5.1.22.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.aop-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.asm-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.beans-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.context-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.context.support-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.core-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.expression-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.jdbc-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.orm-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.transaction-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.web-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFliborg.springframework.web.servlet-3.1.2.RELEASE.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibpoi-3.14-20160307.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibpoi-ooxml-3.14-20160307.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibpoi-ooxml-schemas-3.14-20160307.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibquartz-1.6.4.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlib t.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibxmlbeans-2.6.0.jar;E:MyEclipse Professional 2014MyEclipsesinasoftworkspaceReconciliationPlatformWebRootWEB-INFlibzip4j-1.3.2.jar ---------------------------------------------------------------------- user.name:andong ---------------------------------------------------------------------- java.vm.specification.version:1.7 ---------------------------------------------------------------------- sun.java.command:test.Test ---------------------------------------------------------------------- java.home:E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jre ---------------------------------------------------------------------- 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 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibext;C:WINDOWSSunJavalibext ---------------------------------------------------------------------- sun.boot.class.path:E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelib esources.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelib t.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibsunrsasign.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibjsse.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibjce.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibcharsets.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibjfr.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jreclasses ---------------------------------------------------------------------- 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 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrein ---------------------------------------------------------------------- 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-x86apache-tomcat-6.0.43in ---------------------------------------------------------------------- java.runtime.version:1.7.0_45-b18 ---------------------------------------------------------------------- java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment ---------------------------------------------------------------------- java.endorsed.dirs:E:apache-tomcat-6.0.43-windows-x86apache-tomcat-6.0.43/common/endorsed ---------------------------------------------------------------------- os.arch:amd64 ---------------------------------------------------------------------- java.io.tmpdir:E:apache-tomcat-6.0.43-windows-x86apache-tomcat-6.0.43 emp ---------------------------------------------------------------------- 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 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45in;E:apache-tomcat-6.0.43-windows-x86apache-tomcat-6.0.43in ---------------------------------------------------------------------- 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:Usersandong ---------------------------------------------------------------------- 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-x86apache-tomcat-6.0.43 ---------------------------------------------------------------------- java.class.path:E:apache-tomcat-6.0.43-windows-x86apache-tomcat-6.0.43/bin/bootstrap.jar;E:MyEclipse Professional 2014inarycom.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 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jre ---------------------------------------------------------------------- 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 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibext;C:WINDOWSSunJavalibext ---------------------------------------------------------------------- sun.boot.class.path:E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelib esources.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelib t.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibsunrsasign.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibjsse.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibjce.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibcharsets.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jrelibjfr.jar;E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jreclasses ---------------------------------------------------------------------- server.loader: ---------------------------------------------------------------------- java.vendor:Oracle Corporation ---------------------------------------------------------------------- catalina.base:E:apache-tomcat-6.0.43-windows-x86apache-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:
- 用户当前工作目录 user.dir。需要注意的是在main方法中,指向了当前的项目路径,但是在tomcat中,指向了tomcat的bin目录
- 操作系统名称
os.name。 不过该项并不准确
- java运行时环境版本 java.version:1.7.0_45
- Java 安装目录 java.home:E:MyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_64_1.7.0.u45jre 。该目录是java jre的目录
- 用户的语言 user.language:zh
- 用户名称(计算机名称) user.name:andong ,不过经过测试如果你用微软账户登陆,它这里拿到的还是原来的名字
- 用户所在时区 user.timezone:Asia/Shanghai 不过main方法中并未打印时区
- 还有tomcat下打印了catalina的相关信息:catalina.home:E:apache-tomcat-6.0.43-windows-x86apache-tomcat-6.0.43
- catalina.base:E:apache-tomcat-6.0.43-windows-x86apache-tomcat-6.0.43
这次的测试结果使用的是jdk1.7,tomcat6,windows10,linux下的情况并未测试