需 在eclipse的运行参数(VM arguments:)增加如下的参数:
-Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
然后可用如下代码进行连接:
url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
mbs = jmxc.getMBeanServerConnection();
参考:
http://jiangnanguying.iteye.com/blog/539697