JMX - Standard MBean

> Procedural Languages > Java > Java - Java Management eXtensions (JMX)

Table of Contents

2 - Example

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

package Jmx;
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...");
  • Run it
  • Open Jconsole (jdk/bin/jconsole) and choose your class name

  • In the Mbean tab, you can see the MBean below the com.example node