ITeye博客

java中察看系统属性

klcwt · 2010-09-05 18:05 · 编程语言 · Markdown

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=\

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。