java1.5中访问环境变量

2022-10-20,,

如:
复制代码 代码如下:
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 settings\owner.legend-a7r5pdtm
sessionname=console
tmp=c:\docume~1\owner~1.leg\locals~1\temp
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 settings\owner.legend-a7r5pdtm
pathext=.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh
commonprogramfiles=c:\program files\common files
number_of_processors=1
comspec=c:\windows\system32\cmd.exe
computername=zz3z100
os=windows_nt
username=owner
clientname=console
=exitcode=00000000
temp=c:\docume~1\owner~1.leg\locals~1\temp
userdomain=zz3z100
allusersprofile=c:\documents and settings\all users.windows
processor_level=15
systemroot=c:\windows
classpath=c:\jdk1.5\lib;c:\java
=c:=c:\java
appdata=c:\documents and settings\owner.legend-a7r5pdtm\application data
path=c:\windows\system32;c:\windows;c:\windows\system32\wbem;
c:\jdk1.5\bin;c:\ant1.6\bin
prompt=$p$g
processor_revision=0204
programfiles=c:\program files

c:\java>

《java1.5中访问环境变量.doc》

下载本文的Word格式文档,以方便收藏与打印。