获取环境变量列表

package javabse;

import java.util.Iterator;
import java.util.Map;

/**
* 获取环境变量列表
* @author wxg1022
*
*/
public class TestSystemEnv {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Map<String,String> map=System.getenv();
Iterator<String> it=map.keySet().iterator();
while(it.hasNext()){
String key=(String)it.next();
String value=map.get(key);
System.out.println(key+"="+value);
}
}

}

//执行结果

USERPROFILE=C:\Documents and Settings\wxg1022
ASANY8=C:\Program Files\Sybase\SQL Anywhere 8
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
TEMP=C:\DOCUME~1\wxg1022\LOCALS~1\Temp
SystemDrive=C:
ProgramFiles=C:\Program Files
Path=C:\Program Files\Java\jre6\bin\client;C:\Program Files\Java\jre6\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Sybase\SQL Anywhere 8\win32;C:\Program Files\Sybase\Shared\win32;C:\Program Files\Sybase\Shared\Sybase Central 4.1;C:\Program Files\Sybase\PowerDynamo\win32;C:\Program Files\Sybase\Shared\PowerBuilder;C:\Program Files\Sybase\InfoMaker 9.0\Tutorial;C:\Program Files\Sybase\Shared\Web Targets;;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\Java\jdk1.6.0_11\bin
HOMEDRIVE=C:
java_home=C:\Program Files\Java\jdk1.6.0_11
PROCESSOR_REVISION=0905
USERDOMAIN=WXG
ALLUSERSPROFILE=C:\Documents and Settings\All Users
PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, GenuineIntel
SESSIONNAME=Console
ASANYSH8=C:\Program Files\Sybase\Shared
TMP=C:\DOCUME~1\wxg1022\LOCALS~1\Temp
CommonProgramFiles=C:\Program Files\Common Files
CLASSPATH=.;C:\Program Files\Java\jdk1.6.0_11\lib
=::=::\
LOGONSERVER=\\WXG
PROCESSOR_ARCHITECTURE=x86
FP_NO_HOST_CHECK=NO
OS=Windows_NT
HOMEPATH=\Documents and Settings\wxg1022
PROCESSOR_LEVEL=6
COMPUTERNAME=WXG
windir=C:\WINDOWS
SystemRoot=C:\WINDOWS
NUMBER_OF_PROCESSORS=1
USERNAME=wxg1022
ComSpec=C:\WINDOWS\system32\cmd.exe
APPDATA=C:\Documents and Settings\wxg1022\Application Data

你可能感兴趣的:(C++,c,windows,C#,Sybase)