以这种不同的方式阅读系统属性之间的区别是什么
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean(); Object value = RuntimemxBean.getSystemProperties(); System.out.println(value);
和
Properties systemProperties = System.getProperties(); systemProperties.list(System.out);
解决方法
至少在Sun JVM中,结果应该与RuntimeMXBean.getSystemProperties()内部调用System.getProperties()相同.
public Map<String,String> getSystemProperties() { Properties localProperties = System.getProperties(); HashMap localHashMap = new HashMap(); Set localSet = localProperties.stringPropertyNames(); for (String str1 : localSet) { String str2 = localProperties.getProperty(str1); localHashMap.put(str1,str2); } return localHashMap; }