what is the difference between reading system properties in this different ways
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
Object value = RuntimemxBean.getSystemProperties();
System.out.println(value);
AND
Properties systemProperties = System.getProperties();
systemProperties.list(System.out);
At least in Sun JVM, the result should be the same as RuntimeMXBean.getSystemProperties()
calls System.getProperties()
internally.
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 you can use RuntimeMXBean
from a remote JVM (see 2) to obtain its system properties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With