Java-获取系统的环境变量
package lzh;import java.util.Map;/*** 获取系统的环境变量* 对于windows在系统属性-->高级-->环境变量中设置的变量将显示在此* 对于linux,通过export设置的变量将显示在此* @author lzh**/public class ShowEnv {public static void main(St
·
package lzh;
import java.util.Map;
/**
* 获取系统的环境变量
* 对于windows在系统属性-->高级-->环境变量中设置的变量将显示在此
* 对于linux,通过export设置的变量将显示在此
* @author lzh
*
*/
public class ShowEnv {
public static void main(String[] args) {
//System.out.println(System.getenv()); //直接打印显示
// 遍历显示
Map<String, String> envmap = System.getenv();
for(Map.Entry<String, String> entry:envmap.entrySet()){
System.out.println(entry.getKey()+"--->"+entry.getValue());
}
}
}
/** 结果类似于
LOCALAPPDATA--->C:\Users\lzh\AppData\Local
PROCESSOR_LEVEL--->6FP_NO_HOST_CHECK--->NO
USERDOMAIN--->lzhPC
LOGONSERVER--->\\LZHPC
JAVA_HOME--->C:\Program Files\Java\jdk1.8.0_101
SESSIONNAME--->Console
ALLUSERSPROFILE--->C:\ProgramData
PROCESSOR_ARCHITECTURE--->AMD64
PSModulePath--->C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
SystemDrive--->C:
APPDATA--->C:\Users\lzh\AppData\Roaming
USERNAME--->lzh
windows_tracing_logfile--->C:\BVTBin\Tests\installpackage\csilogfile.log
ProgramFiles(x86)--->C:\Program Files (x86)
CommonProgramFiles--->C:\Program Files\Common Files
Path--->C:/Program Files/Java/jre1.8.0_101/bin/server;C:/Program Files/Java/jre1.8.0_101/bin;C:/Program Files/Java/jre1.8.0_101/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Python27\Lib\site-packages\PyQt4;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\gnuplot\binary;C:\Program Files (x86)\pythonxy\SciTE-3.5.1-4;C:\Program Files (x86)\pythonxy\console;C:\Program Files (x86)\Lenovo\Access Connections\;C:\Users\lzh\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\lzh\AppData\Local\Programs\Python\Python35-32\;D:\eclipse;
PATHEXT--->.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
OS--->Windows_NT
windows_tracing_flags--->3
COMPUTERNAME--->LZHPC
ACPath--->C:\Program Files (x86)\Lenovo\Access Connections\
PROCESSOR_REVISION--->2505
CommonProgramW6432--->C:\Program Files\Common Files
ComSpec--->C:\Windows\system32\cmd.exe
ProgramData--->C:\ProgramData
ProgramW6432--->C:\Program Files
HOMEPATH--->\Users\lzh
SystemRoot--->C:\Windows
TEMP--->C:\Users\lzh\AppData\Local\Temp
ESET_OPTIONS--->
HOMEDRIVE--->C:
PROCESSOR_IDENTIFIER--->Intel64 Family 6 Model 37 Stepping 5, GenuineIntel
USERPROFILE--->C:\Users\lzh
TMP--->C:\Users\lzh\AppData\Local\Temp
CommonProgramFiles(x86)--->C:\Program Files (x86)\Common Files
ProgramFiles--->C:\Program Files
PUBLIC--->C:\Users\Public
NUMBER_OF_PROCESSORS--->4
windir--->C:\Windows
=::--->::\
*/
更多推荐
已为社区贡献1条内容
所有评论(0)