一、JVM已经帮我们读取了系统信息
public void testSystemParam(){ Properties p = System.getProperties(); Iterator it = p.entrySet().iterator(); while(it.hasNext()){ Map.Entry entry = (Map.Entry) it.next(); System.out.println(entry.getKey()+" : "+entry.getValue()); } }
二、Windows下的结果实例
java.runtime.name : Java(TM) SE Runtime Environment sun.boot.library.path : C:Program FilesJavajdk1.8.0_141jrein java.vm.version : 25.141-b15 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 : PID : 2352 java.vm.specification.name : Java Virtual Machine Specification user.dir : E:workspace-idea-gitutms-clientutms-c-worker java.runtime.version : 1.8.0_141-b15 java.awt.graphicsenv : sun.awt.Win32GraphicsEnvironment java.endorsed.dirs : C:Program FilesJavajdk1.8.0_141jrelibendorsed os.arch : amd64 java.io.tmpdir : C:UserskingsomgAppDataLocalTemp line.separator : java.vm.specification.vendor : Oracle Corporation user.variant : os.name : Windows 10 sun.jnu.encoding : GBK spring.beaninfo.ignore : true java.library.path : C:Program FilesJavajdk1.8.0_141in;. java.specification.name : Java Platform API Specification java.class.version : 52.0 sun.management.compiler : HotSpot 64-Bit Tiered Compilers os.version : 10.0 user.home : C:Userskingsomg user.timezone : Asia/Shanghai java.awt.printerjob : sun.awt.windows.WPrinterJob file.encoding : UTF-8 java.specification.version : 1.8 java.class.path : D:Program FilesJetBrainsIntelliJ IDEA Community Edition 2019.1.1libidea_rt.jar; user.name : kingsomg java.vm.specification.version : 1.8 sun.java.command : com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.suning.test.EnvTest java.home : C:Program FilesJavajdk1.8.0_141jre 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.8.0_141 java.ext.dirs : C:Program FilesJavajdk1.8.0_141jrelibext;C:WindowsSunJavalibext sun.boot.class.path : C:Program FilesJavajdk1.8.0_141jrelib esources.jar; java.awt.headless : true java.vendor : Oracle Corporation file.separator : java.vendor.url.bug : http://bugreport.sun.com/bugreport/ idea.test.cyclic.buffer.size : 1048576 sun.io.unicode.encoding : UnicodeLittle sun.cpu.endian : little sun.desktop : windows sun.cpu.isalist : amd64