我最近才接触java,随笔记录一些东西。以免以后忘记。
Properties props=System.getProperties();
Enumeration enum=props.keys();
while(enum.hasMoreElements())
{
String key=(String)enum.nextElement();
System.out.println(key+":"+System.getProperty(key));
}
java通过system.getproperty可以获得环境变量如下:
java.runtime.name:Java(TM) 2 Runtime Environment, Standard Edition
sun.boot.library.path:C:\jdk1.4.1_02\jre\bin
java.vm.version:1.4.1_02-b06
java.vm.vendor:Sun Microsystems Inc.
java.vendor.url:http://java.sun.com/
path.separator:;
java.vm.name:Java HotSpot(TM) Client VM
file.encoding.pkg:sun.io
user.country:CN
sun.os.patch.level:Service Pack 4
java.vm.specification.name:Java Virtual Machine Specification
user.dir:E:\工作目录\java\EnhydraTools\classes
java.runtime.version:1.4.1_02-b06
java.awt.graphicsenv:sun.awt.Win32GraphicsEnvironment
java.endorsed.dirs:C:\jdk1.4.1_02\jre\lib\endorsed
os.arch:x86
java.io.tmpdir:C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\
line.separator:
java.vm.specification.vendor:Sun Microsystems Inc.
user.variant:
os.name:Windows 2000
sun.java2d.fontpath:
java.library.path:C:\jdk1.4.1_02\bin;.;C:\WINNT\system32;C:\WINNT;C:\jdk1.4.1_02
\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;d:\Sybase\CFG-1_0\bin;d:\
Sybase\EFTS-12_5\dll;d:\Sybase\EFTS-12_5\bin;d:\Sybase\OCS-12_5\dll;d:\Sybase\OC
S-12_5\lib3p;d:\Sybase\OCS-12_5\bin;d:\Sybase\ASE-12_5\dll;d:\Sybase\ASE-12_5\bi
n;d:\oracle\ora81\bin;d:\oracle\ora81\Apache\Perl\5.00503\bin\mswin32-x86;C:\Pro
gram Files\Oracle\jre\1.1.7\bin;D:\Program Files\Sybase\Shared\Sun\JDK118\bin;D:
\Program Files\Sybase\Shared\PowerBuilder;d:\Sybase\DLL;d:\Sybase\BIN;d:\Program
Files\Sybase\Sybase Central\win32;d:\Sybase\ASEP;d:\Program Files\Sybase\SQL An
ywhere 8\win32;d:\Program Files\Sybase\Shared\win32;d:\Program Files\Sybase\Shar
ed\Sybase Central 4.1;d:\Program Files\Sybase\Shared\Web Targets;D:\Program File
s\Borland\Delphi7\Bin;D:\Program Files\Borland\Delphi7\Projects\Bpl\;D:\siemens\
SMTK\bin;D:\Enhydra5.0\DODS5.1\bin;d:\enhydra5.0\DODS5.1\bin;d:\jwsdp-1.1\jwsdp-
shared\bin
java.specification.name:Java Platform API Specification
java.class.version:48.0
java.util.prefs.PreferencesFactory:java.util.prefs.WindowsPreferencesFactory
os.version:5.0
user.home:C:\Documents and Settings\Administrator
user.timezone:
java.awt.printerjob:sun.awt.windows.WPrinterJob
file.encoding:GBK
java.specification.version:1.4
java.class.path:.;D:\Program Files\Sybase\Jaguar CTS 3.5\html\classes;D:\Program
Files\Sybase\Jaguar CTS 3.5\java\classes;D:\Program Files\Sybase\Shared\Sun\jdk
118\lib\classes.zip;D:\Program Files\Sybase\Shared\PowerBuilder\classes.zip;C:\j
dk1.4.1_02\jre\lib\rt.jar;C:\Program Files\Apache Group\axis-1_1\lib\axis.jar;C:
\Program Files\Apache Group\axis-1_1\lib\commons-discovery.jar;
user.name:Administrator
java.vm.specification.version:1.0
java.home:C:\jdk1.4.1_02\jre
sun.arch.data.model:32
user.language:zh
java.specification.vendor:Sun Microsystems Inc.
awt.toolkit:sun.awt.windows.WToolkit
java.vm.info:mixed mode
java.version:1.4.1_02
java.ext.dirs:C:\jdk1.4.1_02\jre\lib\ext
sun.boot.class.path:C:\jdk1.4.1_02\jre\lib\rt.jar;C:\jdk1.4.1_02\jre\lib\i18n.ja
r;C:\jdk1.4.1_02\jre\lib\sunrsasign.jar;C:\jdk1.4.1_02\jre\lib\jsse.jar;C:\jdk1.
4.1_02\jre\lib\jce.jar;C:\jdk1.4.1_02\jre\lib\charsets.jar;C:\jdk1.4.1_02\jre\cl
asses
java.vendor:Sun Microsystems Inc.
file.separator:\
java.vendor.url.bug:http://java.sun.com/cgi-bin/bugreport.cgi
sun.io.unicode.encoding:UnicodeLittle
sun.cpu.endian:little
sun.cpu.isalist:pentium i486 i386