Java – use the runtimemxbean instance and system Getproperties reads the difference between system properties

What is the difference between reading system properties in this different way

RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
Object value =  RuntimemxBean.getSystemProperties();
System.out.println(value);

and

Properties systemProperties = System.getProperties();
systemProperties.list(System.out);

Solution

At least in the sun JVM, the result should be the same as runtimemxbean Getsystemproperties() internally calls system Getproperties() is the same

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;
}

The difference is that you can use the runtimemxbean in the remote JVM (see 2) to get its system properties

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>