java1.5中访问环境变量
本文导语: 如: 代码如下:public class EnvTest { public static void main(String args[]) { System.out.println(System.getenv(args[0])); } } 运行结果: C:java>java EnvTest OS Windows_NT 又如: 代码如下:import java.util.Map; public class EnvDump { public static void ...
如:
public class EnvTest {
public static void main(String args[]) {
System.out.println(System.getenv(args[0]));
}
}
运行结果:
C:java>java EnvTest OS
Windows_NT
又如:
import java.util.Map;
public class EnvDump {
public static void main(String args[]) {
for (Map.Entry entry: System.getenv().entrySet()) {
System.out.println(entry.getKey() + "=" + entry.getValue());
}
}
}
运行结果:
C:java>java EnvDump
PROCESSOR_ARCHITECTURE=x86
LOGONSERVER=\ZZ3Z100
HOMEDRIVE=C:
HOMEPATH=Documents and SettingsOwner.LEGEND-A7R5PDTM
SESSIONNAME=Console
TMP=C:DOCUME~1OWNER~1.LEGLOCALS~1Temp
java_home=c:jdk1.5
windir=C:WINDOWS
ant_home=c:ant1.6
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 4, GenuineIntel
SystemDrive=C:
USERPROFILE=C:Documents and SettingsOwner.LEGEND-A7R5PDTM
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
CommonProgramFiles=C:Program FilesCommon Files
NUMBER_OF_PROCESSORS=1
ComSpec=C:WINDOWSsystem32cmd.exe
COMPUTERNAME=ZZ3Z100
OS=Windows_NT
USERNAME=Owner
CLIENTNAME=Console
=ExitCode=00000000
TEMP=C:DOCUME~1OWNER~1.LEGLOCALS~1Temp
USERDOMAIN=ZZ3Z100
ALLUSERSPROFILE=C:Documents and SettingsAll Users.WINDOWS
PROCESSOR_LEVEL=15
SystemRoot=C:WINDOWS
classpath=c:jdk1.5lib;c:java
=C:=C:java
APPDATA=C:Documents and SettingsOwner.LEGEND-A7R5PDTMApplication Data
Path=C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;
c:jdk1.5bin;c:ant1.6bin
PROMPT=$P$G
PROCESSOR_REVISION=0204
ProgramFiles=C:Program Files
C:java>
您可能感兴趣的文章:
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。