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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JAVA获得系统配置文件的System Properties相关的知识,希望对你有一定的参考价值。

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:ProgramFilesJavajdk1.7.0_51jrein
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:WorksworkspaceTT
java.runtime.version===1.7.0_51-b13
java.awt.graphicsenv===sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs===H:ProgramFilesJavajdk1.7.0_51jrelibendorsed
os.arch===x86
java.io.tmpdir===C:UserschenjoAppDataLocalTempline.separator===

java.vm.specification.vendor===Oracle Corporation
user.variant===
os.name===Windows 7
sun.jnu.encoding===GBK
java.library.path===H:ProgramFilesJavajdk1.7.0_51in;C:WindowsSunJavain;C:Windowssystem32;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%in;C:Program Files (x86)Common FilesOracleJavajavapath;H:ProgramFiles(x86)NetSarangXshell6;H:ProgramFilesPython3;H:ProgramFilesPython3Scripts;H:ProgramFilesPython3Scripts;H:ProgramFilesPython3;H:oraclexeapporacleproduct11.2.0serverin;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;H:AppsSikuliX;C:Program FilesMicrosoft SQL Server130ToolsBinn;H:ProgramFiles
odejs;h:ProgramFilesCloudFoundry;H:ProgramFilesPuTTY;H:ProgramFilesTortoiseSVNin;C:Program FilesMicrosoft VS Codein;h:ProgramFilesGitcmd;G:Goin;H:Appsgradle-4.8.1in;H:ProgramFilesPython27;H:AppsJspStudyMySQLin;H:ProgramFilesJavajdk1.8.0_212in;H:Appsspring-boot-cli-1.4.2in;H:Appsmaven-3.2.3in;H:AppsRuby193in;G:programsSikuli-1.0.1libs;.;H:Appsjython2.5.3;H:Appsgroovy-2.5.7in;H:Appsscala-2.11.4in;H:Appsapache-ant-1.9.4in;H:ProgramFilesPython3;H:ProgramFilesPython3Scripts;G:goin;G:mygoin;H:Appssbtin;G:programsSikuli-1.0.1;G:programsSikuli-1.0.1libs;H:Appssqlite-shell-3.8.8.2;H:ProgramFiles(x86)CodeBlocksMinGWin;C:UserschenjoAppDataRoaming
pm;C:UserschenjoAppDataRoaming
pm;;C:Program FilesMicrosoft VS Codein;C:Userschenjogoin;h:ProgramFilesJetBrainsIntelliJIDEA2019.1.3in;;h:ProgramFilesJetBrainsGoLand2019.3in;;;H:Appseclipse-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:Userschenjo
user.timezone===
java.awt.printerjob===sun.awt.windows.WPrinterJob
file.encoding===UTF-8
java.specification.version===1.7
java.class.path===H:WorksworkspaceTTin
user.name===chenjo
java.vm.specification.version===1.7
sun.java.command===SystemProperties
java.home===H:ProgramFilesJavajdk1.7.0_51jre
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:ProgramFilesJavajdk1.7.0_51jrelibext;C:WindowsSunJavalibext
sun.boot.class.path===H:ProgramFilesJavajdk1.7.0_51jrelib
esources.jar;H:ProgramFilesJavajdk1.7.0_51jrelib
t.jar;H:ProgramFilesJavajdk1.7.0_51jrelibsunrsasign.jar;H:ProgramFilesJavajdk1.7.0_51jrelibjsse.jar;H:ProgramFilesJavajdk1.7.0_51jrelibjce.jar;H:ProgramFilesJavajdk1.7.0_51jrelibcharsets.jar;H:ProgramFilesJavajdk1.7.0_51jrelibjfr.jar;H:ProgramFilesJavajdk1.7.0_51jreclasses
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

以上是关于JAVA获得系统配置文件的System Properties的主要内容,如果未能解决你的问题,请参考以下文章

Confluence 6 配置校验和识别

Confluence 6 配置校验和识别

Java学习笔记5.4.3 Map接口 - Properties类

身份验证中的问题

spring读取properties配置

java中怎么获得tomcat路径