代码改变世界

JAVA获得系统配置文件的System Properties

2020-05-24 19:59  jetwill  阅读(554)  评论(0编辑  收藏  举报

Code:

import java.util.*;
import java.util.Map.Entry;

public class SystemProperties
{
    public static void main(String[] args)
    {
        Properties properties = System.getProperties();
        Iterator<Entry<Object, Object>> iterator = properties.entrySet().iterator();
        while (iterator.hasNext())
        {
            Entry<Object, Object> entry = iterator.next();
            System.out.println(entry.getKey() + "===" + entry.getValue());
        }
    }
}

Result:

java.runtime.name===Java(TM) SE Runtime Environment
sun.boot.library.path===H:\ProgramFiles\Java\jdk1.7.0_51\jre\bin
java.vm.version===24.51-b03
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.country===CN
user.script===
sun.java.launcher===SUN_STANDARD
sun.os.patch.level===Service Pack 1
java.vm.specification.name===Java Virtual Machine Specification
user.dir===H:\Works\workspace\TT
java.runtime.version===1.7.0_51-b13
java.awt.graphicsenv===sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs===H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\endorsed
os.arch===x86
java.io.tmpdir===C:\Users\chenjo\AppData\Local\Temp\
line.separator===

java.vm.specification.vendor===Oracle Corporation
user.variant===
os.name===Windows 7
sun.jnu.encoding===GBK
java.library.path===H:\ProgramFiles\Java\jdk1.7.0_51\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;H:/ProgramFiles/Java/jre1.8.0_212/bin/server;H:/ProgramFiles/Java/jre1.8.0_212/bin;H:/ProgramFiles/Java/jre1.8.0_212/lib/amd64;%MYSQL_HOME%\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;H:\ProgramFiles(x86)\NetSarang\Xshell6\;H:\ProgramFiles\Python3\;H:\ProgramFiles\Python3\Scripts;H:\ProgramFiles\Python3\Scripts\;H:\ProgramFiles\Python3\;H:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;H:\Apps\SikuliX;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;H:\ProgramFiles\nodejs\;h:\ProgramFiles\CloudFoundry;H:\ProgramFiles\PuTTY\;H:\ProgramFiles\TortoiseSVN\bin;C:\Program Files\Microsoft VS Code\bin;h:\ProgramFiles\Git\cmd;G:\Go\bin;H:\Apps\gradle-4.8.1\bin;H:\ProgramFiles\Python27;H:\Apps\JspStudy\MySQL\bin;H:\ProgramFiles\Java\jdk1.8.0_212\bin;H:\Apps\spring-boot-cli-1.4.2\bin;H:\Apps\maven-3.2.3\bin;H:\Apps\Ruby193\bin;G:\programs\Sikuli-1.0.1\libs;.;H:\Apps\jython2.5.3;H:\Apps\groovy-2.5.7\bin;H:\Apps\scala-2.11.4\bin;H:\Apps\apache-ant-1.9.4\bin;H:\ProgramFiles\Python3\;H:\ProgramFiles\Python3\Scripts;G:\go\bin;G:\mygo\bin;H:\Apps\sbt\bin;G:\programs\Sikuli-1.0.1;G:\programs\Sikuli-1.0.1\libs;H:\Apps\sqlite-shell-3.8.8.2;H:\ProgramFiles(x86)\CodeBlocks\MinGW\bin;C:\Users\chenjo\AppData\Roaming\npm;C:\Users\chenjo\AppData\Roaming\npm;;C:\Program Files\Microsoft VS Code\bin;C:\Users\chenjo\go\bin;h:\ProgramFiles\JetBrains\IntelliJIDEA2019.1.3\bin;;h:\ProgramFiles\JetBrains\GoLand2019.3\bin;;;H:\Apps\eclipse-jee-indigo;;.
java.specification.name===Java Platform API Specification
java.class.version===51.0
sun.management.compiler===HotSpot Client Compiler
os.version===6.1
user.home===C:\Users\chenjo
user.timezone===
java.awt.printerjob===sun.awt.windows.WPrinterJob
file.encoding===UTF-8
java.specification.version===1.7
java.class.path===H:\Works\workspace\TT\bin
user.name===chenjo
java.vm.specification.version===1.7
sun.java.command===SystemProperties
java.home===H:\ProgramFiles\Java\jdk1.7.0_51\jre
sun.arch.data.model===32
user.language===zh
java.specification.vendor===Oracle Corporation
awt.toolkit===sun.awt.windows.WToolkit
java.vm.info===mixed mode, sharing
java.version===1.7.0_51
java.ext.dirs===H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\ext;C:\Windows\Sun\Java\lib\ext
sun.boot.class.path===H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\resources.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\rt.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\sunrsasign.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\jsse.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\jce.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\charsets.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\lib\jfr.jar;H:\ProgramFiles\Java\jdk1.7.0_51\jre\classes
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===pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86