前言:

在web编程技术内幕中看到一个用apache组件进行文件下载的例子,对于DiskFileUpload类的setRepositoryPath方法,设置临时文件的存放路径,里面指出如果不调用该方法指定绝对路径。那么会使用"java.io.tempdir"这个环境属性的值。想到前面没有遇到过这个环境属性,这里列举出所有环境属性。代码如下:

         Properties properties = System.getProperties();
Enumeration names = properties.propertyNames();
String propertyName;
while (names.hasMoreElements()) {
propertyName = (String) names.nextElement();
System.out.print(propertyName + ":");
System.out.println(properties.getProperty(propertyName));
}

getSysProps

运行结果如下:

 java.runtime.name:Java(TM) SE Runtime Environment
sun.boot.library.path:E:\MyEclipse\JDK\1.8\jre\bin
java.vm.version:25.101-b13
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
idea.launcher.port:7535
user.script:
user.country:CN
sun.java.launcher:SUN_STANDARD
sun.os.patch.level:Service Pack 1
java.vm.specification.name:Java Virtual Machine Specification
user.dir:E:\MyEclipse\workspace\ScriptEngine
java.runtime.version:1.8.0_101-b13
java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs:E:\MyEclipse\JDK\1.8\jre\lib\endorsed
os.arch:amd64
java.io.tmpdir:C:\Users\ADMINI~1\AppData\Local\Temp\
line.separator: java.vm.specification.vendor:Oracle Corporation
user.variant:
os.name:Windows 7
sun.jnu.encoding:GBK
java.library.path:E:\MyEclipse\JDK\1.8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;E:\Tools\jruby-9.1.2.0\bin;E:\MyEclipse\JDK\1.8\bin;C:\ProgramData\Oracle\Java\javapath;E:\Tools\jruby-9.1.2.0\bin;E:\Tools\Python3.6\Scripts\;E:\Tools\Python3.6\;.
java.specification.name:Java Platform API Specification
java.class.version:52.0
sun.management.compiler:HotSpot 64-Bit Tiered Compilers
os.version:6.1
user.home:C:\Users\Administrator
user.timezone:
java.awt.printerjob:sun.awt.windows.WPrinterJob
java.specification.version:1.8
file.encoding:UTF-8
idea.launcher.bin.path:E:\IntelliJ IDEA 2016.2.2\bin
user.name:Administrator
java.class.path:E:\MyEclipse\workspace\ScriptEngine\bin;E:\Tools\jpython\jython.jar;E:\MyEclipse\JDK\1.8\jre\lib\charsets.jar;E:\MyEclipse\JDK\1.8\jre\lib\deploy.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\access-bridge-64.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\cldrdata.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\dnsns.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\jaccess.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\jfxrt.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\localedata.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\nashorn.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\sunec.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\sunjce_provider.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\sunmscapi.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\sunpkcs11.jar;E:\MyEclipse\JDK\1.8\jre\lib\ext\zipfs.jar;E:\MyEclipse\JDK\1.8\jre\lib\javaws.jar;E:\MyEclipse\JDK\1.8\jre\lib\jce.jar;E:\MyEclipse\JDK\1.8\jre\lib\jfr.jar;E:\MyEclipse\JDK\1.8\jre\lib\jfxswt.jar;E:\MyEclipse\JDK\1.8\jre\lib\jsse.jar;E:\MyEclipse\JDK\1.8\jre\lib\management-agent.jar;E:\MyEclipse\JDK\1.8\jre\lib\plugin.jar;E:\MyEclipse\JDK\1.8\jre\lib\resources.jar;E:\MyEclipse\JDK\1.8\jre\lib\rt.jar;E:\Tools\jruby-9.1.2.0\lib\jruby.jar;E:\IntelliJ IDEA 2016.2.2\lib\idea_rt.jar
java.vm.specification.version:1.8
sun.arch.data.model:64
java.home:E:\MyEclipse\JDK\1.8\jre
sun.java.command:com.intellij.rt.execution.application.AppMain TestRuby
java.specification.vendor:Oracle Corporation
user.language:zh
awt.toolkit:sun.awt.windows.WToolkit
java.vm.info:mixed mode
java.version:1.8.0_101
java.ext.dirs:E:\MyEclipse\JDK\1.8\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path:E:\MyEclipse\JDK\1.8\jre\lib\resources.jar;E:\MyEclipse\JDK\1.8\jre\lib\rt.jar;E:\MyEclipse\JDK\1.8\jre\lib\sunrsasign.jar;E:\MyEclipse\JDK\1.8\jre\lib\jsse.jar;E:\MyEclipse\JDK\1.8\jre\lib\jce.jar;E:\MyEclipse\JDK\1.8\jre\lib\charsets.jar;E:\MyEclipse\JDK\1.8\jre\lib\jfr.jar;E:\MyEclipse\JDK\1.8\jre\classes
java.vendor:Oracle Corporation
file.separator:\
java.vendor.url.bug:http://bugreport.sun.com/bugreport/
sun.cpu.endian:little
sun.io.unicode.encoding:UnicodeLittle
sun.desktop:windows
sun.cpu.isalist:amd64

Result

05-04 12:23