import javax.management.StandardMBean; import javax.management.ObjectName; import javax.management.NotCompliantMBeanException; import javax.management.MBeanRegistrationException; import javax.management.InstanceAlreadyExistsException; import javax.management.MalformedObjectNameException; import java.lang.management.ManagementFactory; public class Main { public static void main(String[] args) throws NotCompliantMBeanException, MBeanRegistrationException, InstanceAlreadyExistsException, MalformedObjectNameException, InterruptedException { ManagementFactory.getPlatformMBeanServer().registerMBean(new StandardMBean(new MBeanImpl(), MBean.class), ObjectName.getInstance("test:name=MBean")); Thread.currentThread().join(); } public static interface MBean { void setValue(int value); int getValue(); } public static class MBeanImpl implements MBean { private int value; public void setValue(int value) { this.value = value; } public int getValue() { return value; } } }