---
title: "java中察看系统属性 "
author: "klcwt"
date: "2010-09-05T18:05:56Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2010-09-05T18:05:56Z"
id: 756003
url: "https://klcwt.iteye.com/blog/756003"
---

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&lt;String, String&gt; systemproperty = new HashMap&lt;String, String&gt;();

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&lt;String&gt; 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=\\