Table of Contents

JMX - Standard MBean

Example

From Java Management Extensions (JMX) (API, Tutorial)

package Jmx;

import java.lang.management.*;
import javax.management.*;

public static void main(String[] args) throws Exception {

        // A JMX Agent is just a process that starts a MBean Server.
        // Getting the server
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        // Construct an (JMX) object name from the given string.
        // com.example is the directory path to the MBean in the MBean explorer
        ObjectName name = new ObjectName("com.example:type=Hello");

        // Register it
        Hello mbean = new Hello();
        mbs.registerMBean(mbean, name);

        // And the process never end
        System.out.println("Waiting forever...");
        Thread.sleep(Long.MAX_VALUE);

    }

Jconsole New Connection Jmxhello

Jconsole Mbean Hello