本文整理汇总了Java中javax.management.InstanceAlreadyExistsException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java InstanceAlreadyExistsException.printStackTrace方法的具体用法?Java InstanceAlreadyExistsException.printStackTrace怎么用?Java InstanceAlreadyExistsException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.InstanceAlreadyExistsException
的用法示例。
在下文中一共展示了InstanceAlreadyExistsException.printStackTrace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.management.InstanceAlreadyExistsException; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
boolean expectException =
(System.getProperty("jmx.mxbean.multiname") == null);
try {
ObjectName objectName1 = new ObjectName("test:index=1");
ObjectName objectName2 = new ObjectName("test:index=2");
MBeanServer mbs = MBeanServerFactory.createMBeanServer();
MXBC_SimpleClass01 mxBeanObject = new MXBC_SimpleClass01();
mbs.registerMBean(mxBeanObject, objectName1);
mbs.registerMBean(mxBeanObject, objectName2);
if (expectException) {
throw new Exception("TEST FAILED: " +
"InstanceAlreadyExistsException was not thrown");
} else
System.out.println("Correctly got no exception with compat property");
} catch (InstanceAlreadyExistsException e) {
if (expectException) {
System.out.println("Got expected InstanceAlreadyExistsException:");
e.printStackTrace(System.out);
} else {
throw new Exception(
"TEST FAILED: Got exception even though compat property set", e);
}
}
System.out.println("TEST PASSED");
}