Java tutorial
//package com.java2s; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import java.lang.management.ManagementFactory; import java.util.ArrayList; public class Main { public static MBeanServer findMBeanServer() { ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); if (servers == null || servers.isEmpty()) { return ManagementFactory.getPlatformMBeanServer(); } return servers.get(0); } }