虚拟机修改系统参数信息

通过System.getProperties() 可以获取运行时的系统参数

代码示例:

  @Test
    public void properties() throws IOException {
        Properties properties = System.getProperties();
        Set<Map.Entry<Object, Object>> entries = properties.entrySet();
        for(Map.Entry<Object,Object> entry:entries){
            System.out.println(entry.getKey()+" "+entry.getValue());
        }
    }

输出:

java.runtime.name Java(TM) SE Runtime Environment
sun.boot.library.path E:\ruanjian\jdkAll\JDK8\jre\bin
java.vm.version 25.40-b25
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 H:\testCode\java
java.runtime.version 1.8.0_40-b25
java.awt.graphicsenv sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs E:\ruanjian\jdkAll\JDK8\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 8.1
sun.jnu.encoding GBK
java.library.path E:\ruanjian\jdkAll\JDK8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;F:\software\xshell\;E:\ruanjian\jdkAll\JDK8\bin;E:\ruanjian\jdkAll\jdk13\jdk\bin;E:\ruanjian\python\Scripts;E:\ruanjian\Oracle\product\11.2.0\dbhome_3\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;E:\ruanjian\Git\bin;E:\ruanjian\python;E:\ruanjian\OpenSSH\bin;E:\ruanjian\phpstudy\PHPTutorial\Apache\apache-maven-3.6.3\bin;E:\ruanjian\phpstudy\PHPTutorial\MySQL\bin;F:\software\node-v10.21.0-win-x64;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin;E:\ruanjian\IntelliJ IDEA 2020.1.2\bin;C:\Users\Administrator\AppData\Roaming\npm;F:\software\NodeJs\nvm-version;F:\software\NodeJs\nodejs;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin;E:\ruanjian\IntelliJ IDEA 2020.1.2\bin;C:\Users\Administrator\AppData\Roaming\npm;C:\Program Files\nodejs;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;E:\ruanjian\Dev-Cpp\MinGW64\bin;F:\software\scrcpy;F:\software\NodeJs\;F:\software\gradle-6.1.1-all\gradle-6.1.1\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\bin;E:\ruanjian\IntelliJ IDEA 2020.1.2\bin;;C:\Users\Administrator\AppData\Roaming\npm;.
java.specification.name Java Platform API Specification
java.class.version 52.0
sun.management.compiler HotSpot 64-Bit Tiered Compilers
os.version 6.3
user.home C:\Users\Administrator
user.timezone GMT+08:00
java.awt.printerjob sun.awt.windows.WPrinterJob
file.encoding UTF-8
java.specification.version 1.8
java.class.path F:\software\IntelliJ IDEA 2020.2.1\lib\idea_rt.jar;F:\software\IntelliJ IDEA 2020.2.1\plugins\junit\lib\junit5-rt.jar;F:\software\IntelliJ IDEA 2020.2.1\plugins\junit\lib\junit-rt.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\charsets.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\deploy.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\access-bridge-64.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\cldrdata.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\dnsns.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\jaccess.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\jfxrt.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\localedata.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\nashorn.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\sunec.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\sunjce_provider.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\sunmscapi.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\sunpkcs11.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\ext\zipfs.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\javaws.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jce.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jfr.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jfxswt.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jsse.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\management-agent.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\plugin.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\resources.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\rt.jar;F:\software\IntelliJ IDEA 2020.2.1\lib\junit-4.12.jar;F:\software\IntelliJ IDEA 2020.2.1\lib\hamcrest-core-1.3.jar;H:\testCode\java\out\test\java;H:\testCode\java\out\production\java;F:\software\IntelliJ IDEA 2020.2.1\lib\idea_rt.jar
user.name Administrator
java.vm.specification.version 1.8
sun.java.command com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 com.sallai.ml.Myproperties.Myproperties,properties
java.home E:\ruanjian\jdkAll\JDK8\jre
sun.arch.data.model 64
user.language jp
java.specification.vendor Oracle Corporation
awt.toolkit sun.awt.windows.WToolkit
java.vm.info mixed mode
java.version 1.8.0_40
java.ext.dirs E:\ruanjian\jdkAll\JDK8\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path E:\ruanjian\jdkAll\JDK8\jre\lib\resources.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\rt.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\sunrsasign.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jsse.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jce.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\charsets.jar;E:\ruanjian\jdkAll\JDK8\jre\lib\jfr.jar;E:\ruanjian\jdkAll\JDK8\jre\classes
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

这些参数可以通过 运行参数传递个jvm虚拟机,来覆盖掉对应值。
例如修改 用户语言

-Duser.language=jp

其他同理

上一篇:ThreadLocal源码解析(基于JDK8)


下一篇:【JDK8】Lambda表达式