本文整理汇总了Java中java.lang.management.RuntimeMXBean.getSystemProperties方法的典型用法代码示例。如果您正苦于以下问题:Java RuntimeMXBean.getSystemProperties方法的具体用法?Java RuntimeMXBean.getSystemProperties怎么用?Java RuntimeMXBean.getSystemProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.management.RuntimeMXBean
的用法示例。
在下文中一共展示了RuntimeMXBean.getSystemProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
// Print detail on jvm so we know what is different should below test fail.
RuntimeMXBean b = ManagementFactory.getRuntimeMXBean();
LOG.info("name=" + b.getName());
LOG.info("specname=" + b.getSpecName());
LOG.info("specvendor=" + b.getSpecVendor());
LOG.info("vmname=" + b.getVmName());
LOG.info("vmversion=" + b.getVmVersion());
LOG.info("vmvendor=" + b.getVmVendor());
Map<String, String> p = b.getSystemProperties();
LOG.info("properties=" + p);
}
示例2: runTest
import java.lang.management.RuntimeMXBean; //导入方法依赖的package包/类
private static void runTest() throws Exception {
RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean();
// Print all system properties
Map<String,String> props = mbean.getSystemProperties();
printProperties(props);
// Add new system properties
System.setProperty(KEY1, VALUE1);
System.setProperty(KEY2, VALUE2);
Map<String,String> props1 = mbean.getSystemProperties();
String value1 = props1.get(KEY1);
if (value1 == null || !value1.equals(VALUE1)) {
throw new RuntimeException(KEY1 + " property found" +
" with value = " + value1 +
" but expected to be " + VALUE1);
}
String value2 = props1.get(KEY2);
if (value2 == null || !value2.equals(VALUE2)) {
throw new RuntimeException(KEY2 + " property found" +
" with value = " + value2 +
" but expected to be " + VALUE2);
}
String value3 = props1.get(KEY3);
if (value3 != null) {
throw new RuntimeException(KEY3 + " property found" +
" but should not exist" );
}
// Add new system properties but are not Strings
Properties sp = System.getProperties();
sp.put(KEY3, VALUE3);
sp.put(KEY4, VALUE4);
Map<String,String> props2 = mbean.getSystemProperties();
// expect the system properties returned should be
// same as the one before adding KEY3 and KEY4
if (!props1.equals(props2)) {
throw new RuntimeException("Two copies of system properties " +
"are expected to be equal");
}
System.out.println("Test passed.");
}