wangunix 发表于 2013-1-15 03:08:33

读取系统属性

String   javaVersion   =   System.getProperty("java.version");   
String   javaVendor   =   System.getProperty("java.vendor");   
String   javaVendorUrl   =   System.getProperty("java.vendor.url");   
String   javaHome   =   System.getProperty("java.home");   
String   javaVmSpecificationVersion   =   System.getProperty("java.vm.specification.version");   
String   javaVmSpecificationVendor   =   System.getProperty("java.vm.specification.vendor");   
String   javaVmSpecificationName   =   System.getProperty("java.vm.specification.name");   
String   javaVmVersion   =   System.getProperty("java.vm.version");   
String   javaVmVendor   =   System.getProperty("java.vm.vendor");   
String   javaVmName   =   System.getProperty("java.vm.name");   
String   javaSpecificationVersion   =   System.getProperty("java.specification.version");   
String   javaSpecificationVendor   =   System.getProperty("java.specification.vendor");   
String   javaSpecificationName   =   System.getProperty("java.specification.name");   
String   javaClassVersion   =   System.getProperty("java.class.version");   
String   javaClassPath   =   System.getProperty("java.class.path");   
String   javaLibraryPath   =   System.getProperty("java.library.path");   
String   javaIoTmpdir   =   System.getProperty("java.io.tmpdir");   
String   javaCompiler   =   System.getProperty("java.compiler");   
String   javaExtDirs   =   System.getProperty("java.ext.dirs");   
String   osName   =   System.getProperty("os.name");   
String   osArch   =   System.getProperty("os.arch");   
String   osVersion   =   System.getProperty("os.version");   
String   fileSeparator   =   System.getProperty("file.separator");   
String   pathSeparator   =   System.getProperty("path.separator");   
String   lineSeparator   =   System.getProperty("line.separator");   
String   userName   =   System.getProperty("user.name");   
String   userHome   =   System.getProperty("user.home");   
String   userDir   =   System.getProperty("user.dir");   
String   encode   =   System.getProperty("file.encoding")

-------------------------------------------------------------------------

--------------------------------------------
Set keyset = System.getProperties().keySet();

for(Iterator itr = keyset.iterator(); itr.hasNext();){

String key = (String)itr.next();
String val = System.getProperty(key);
logger.warn("----------->" + key + "<===========>" + val);

}
---------------------------------------------
测试用代码
---------------------------------------------
import java.util.Iterator;
import java.util.Set;

public class showcurr {

public static void main(String arg[]) {

Set keyset = System.getProperties().keySet();

for(Iterator itr = keyset.iterator(); itr.hasNext();){

String key = (String)itr.next();
String val = System.getProperty(key);
System.out.println("----------->" + key + "<===========>" + val);

}

}

}
页: [1]
查看完整版本: 读取系统属性