`
klcwt
  • 浏览: 189437 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

java中察看系统属性

阅读更多

 java中察看系统属性。代码很简单没啥技术含量 但还是值得一记,希望对大家有帮助。。呵呵

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import java.util.Map;

public class Systemproperties {

public static void main(String[] args) {
Map<String, String> systemproperty = new HashMap<String, String>();

systemproperty.put("encoding", System.getProperty("file.encoding"));
systemproperty.put("os", System.getProperty("os.name"));
systemproperty.put("jvm_version", System.getProperty("java.version"));
systemproperty.put("user_home", System.getProperty("user.home"));
systemproperty.put("file_separator", System.getProperty("file.separator"));
systemproperty.put("user_dir", System.getProperty("user.dir"));
systemproperty.put("user_name", System.getProperty("user.name"));
systemproperty.put("os_orch", System.getProperty("os.orch"));
systemproperty.put("class_path", System.getProperty("java.class.path"));
systemproperty.put("vender_url", System.getProperty("java.vendor.url"));
systemproperty.put("vender", System.getProperty("java.vendor"));
Set<String> set = systemproperty.keySet();

for (Iterator iterator = set.iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
String value = systemproperty.get(key);
System.err.println(key + "=" + value);

}

}
}
输出结果:
user_name=jetshi0125
encoding=GBK
class_path=D:\JavaWebPro\j2se_test\bin
user_dir=D:\JavaWebPro\j2se_test
jvm_version=1.5.0_11
os=Windows XP
user_home=C:\Documents and Settings\jetshi0125
vender_url=http://java.sun.com/
vender=Sun Microsystems Inc.
os_orch=null
file_separator=\
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics