1.系统常用属性
我们在框架中经常会使用到系统属性,但是有哪些属性可以用,很多人其实并没有关注。你知道多少决定了你的解决方案的多少。
Properties properties = System.getProperties();
Enumeration<?> enumeration = properties.propertyNames();
while(enumeration.hasMoreElements()){
Object key = enumeration.nextElement();
System.out.println(key+":"+properties.get(key).toString());
}
2.系统属性
java.runtime.name:Java(TM) SE Runtime Environment
sun.boot.library.path:E:\develop\JDK8\jre\bin
java.vm.version:25.144-b01
java.vm.vendor:Oracle Corporation
java.vendor.url:http://java.oracle.com/
path.separator:;
java.vm.name:Java HotSpot(TM) Client VM
file.encoding.pkg:sun.io
user.script:
user.country:CN
sun.java.launcher:SUN_STANDARD
sun.os.patch.level:
java.vm.specification.name:Java Virtual Machine Specification
user.dir:D:\ideaspace\moka-service
java.runtime.version:1.8.0_144-b01
java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs:E:\develop\JDK8\jre\lib\endorsed
os.arch:x86
java.io.tmpdir:C:\Users\amose\AppData\Local\Temp\
line.separator:
java.vm.specification.vendor:Oracle Corporation
user.variant:
os.name:Windows 10
sun.jnu.encoding:GBK
java.library.path:E:\develop\JDK8\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;...
java.specification.name:Java Platform API Specification
java.class.version:52.0
sun.management.compiler:HotSpot Client Compiler
os.version:10.0
user.home:C:\Users\amose
user.timezone:
java.awt.printerjob:sun.awt.windows.WPrinterJob
file.encoding:UTF-8
java.specification.version:1.8
user.name:amose
java.class.path:E:\develop\JDK8\jre\lib\charsets.jar;E:\develop\JDK8\jre\lib\deploy.jar...
java.vm.specification.version:1.8
sun.arch.data.model:32
java.home:E:\develop\JDK8\jre
sun.java.command:com.muyi.mokaservice.Main
java.specification.vendor:Oracle Corporation
user.language:zh
awt.toolkit:sun.awt.windows.WToolkit
java.vm.info:mixed mode
java.version:1.8.0_144
java.ext.dirs:E:\develop\JDK8\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
sun.boot.class.path:E:\develop\JDK8\jre\lib\resources.jar;E:\develop\JDK8\jre\lib\rt.jar;E:\develop\JDK8\jre\lib\sunrsasign.jar;E:\develop\JDK8\jre\lib\jsse.jar;E:\develop\JDK8\jre\lib\jce.jar;E:\develop\JDK8\jre\lib\charsets.jar;E:\develop\JDK8\jre\lib\jfr.jar;E:\develop\JDK8\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:pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
3.系统属性的使用
//项目根目录
String root = System.getProperty("user.dir").toString();