package org.kodejava.lang.management;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.Map;
import java.util.Set;
public class GetSystemProperties {
public static void main(String[] args) {
RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
// Returns a map of names and values of all system
// properties. This method calls System.getProperties()
// to get all system properties. Properties whose
// name or value is not a String are omitted.
Map<String, String> systemProperties = bean.getSystemProperties();
Set<String> keys = systemProperties.keySet();
for (String key : keys) {
String value = systemProperties.get(key);
System.out.printf("Property[%s] = %s%n", key, value);
}
}
}
Some properties produced by the code snippet above are:
Property[java.specification.version] = 17
Property[sun.cpu.isalist] = amd64
Property[sun.jnu.encoding] = Cp1252
Property[java.vm.vendor] = Oracle Corporation
Property[sun.arch.data.model] = 64
Property[user.variant] =
Property[java.vendor.url] = https://java.oracle.com/
...
...
Property[java.vm.info] = mixed mode, sharing.
Property[java.vendor] = Oracle Corporation.
Property[java.vm.version] = 17+35-LTS-2724.
Property[sun.io.unicode.encoding] = UnicodeLittle.
Property[java.class.version] = 61.0.
Latest posts by Wayan (see all)
- How do I build simple search page using ZK and Spring Boot? - March 8, 2023
- How do I calculate days between two dates excluding weekends and holidays? - January 12, 2023
- How do I discover the quarter of a given date? - January 11, 2023