JMXServiceURL address = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi");
JMXConnector connector = JMXConnectorFactory.connect(address);
MBeanServerConnection mbs = connector.getMBeanServerConnection();
ObjectName oname = new ObjectName(
ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
// Memory Usage factors
if(mbs.isInstanceOf(oname,"com.sun.management.OperatingSystemMXBean")) {
// Get platform-specific attribute "ProcessCpuTime"
long cpuTime = (Long) mbs.getAttribute(oname, "ProcessCpuTime");
System.out.println("process cpu time " + cpuTime);
}
[i]when i am executing this piece of code i get an error sayin:[/i]
[b]java.lang.LinkageError: javax/management/MBeanServerConnection[/b]
[Message sent by forum member 'na_d']
http://forums.java.net/jive/thread.jspa?messageID=398020