The NetBeans JMX Module integrates JMX technology right into your workflow in the NetBeans IDE. This module allows you to quickly develop management applications, add management to existing applications, develop manager applications, and monitor the state of the Virtual Machine.
This document has been updated for the JMX Wizard module version 3.0, for NetBeans IDE 6.5 and newer, and running on top of JDK 6 or JDK 7. You can download the JMX module from the Update Center.
Note: This document is a short and quick introduction to the JMX module for NetBeans IDE. For more detailed information, complete the JMX Module Tutorial Adding JMX Instrumentation to a Java Application.
This getting started document gives you an overview of the JMX module features:
This tutorial assumes you have some basic knowledge of, or programming experience with, the following technologies.
You will also benefit from having some knowledge on Monitoring and Management for the Java Platform
For this tutorial you need to have the following software installed on your computer:
|Software or Resource||Version Required|
|NetBeans IDE||7.0, 7.1, 7.2, 7.3, Java bundle|
|Java Development Kit (JDK)||version 6 or 7|
|JMX plugin||Available from NetBeans Update Center|
|JConsole plugin||Available from NetBeans Update Center|
To install the JMX and JConsole plugins, choose Tools > Plugins and download the modules from the NetBeans Update Center.
After you have installed the JMX plugin and your project is open, you can access the JMX wizard by choose File > New File (Ctrl-N) and selecting the JMX category. You can then choose among the following:
You can add attributes and operations to your MBeans with the JMX contextual menu actions, which will popup a dialog box. You can also have your MBeans implement the NotificationEmitter interface.
To update an MBean, either select the MBean class Java file in the Project tree and access the JMX popup menu by right-clicking on the node, or simply right-click in the editor's window where your MBean class Java file is opened and access the JMX popup menu.
These actions are demonstrated in Exercise 3 of the Adding JMX Instrumentation to a Java Application tutorial.
To remotely connect to your MBeans and manage your application, your MBeans need to be registered into an MBean Server.
An MBean Server is the main central piece of the JMX technology. It keeps reference of all MBean registered into it, can send notifications of new MBean registration or deletion, and can accept remote connections to expose attributes and operations of its registered MBeans. If you are not familiar with MBean Server role, read the javax.management.MBeanServer API documentation.
Starting with JDK 5, the Java Platform provides a default MBean Server, called the Platform MBean Server. It enables you to monitor the JVM, but you can also use it to register your own MBeans into it. For details on the Java Platform MBean Server, read the java.lang.management.ManagementFactory API documentation.
Depending on its logic, determine where in your application code you want your MBeans to be registered, typically in the initialization phase of your Main class. Right-Click in your editor's window at the location where you want the MBean's registration code to be generated, select the JMX submenu and then the "Generate MBean Registration..." action.
This action is demonstrated in Exercise 5 of the Adding JMX Instrumentation to a Java Application tutorial.
JConsole is a JMX-compliant graphical tool for monitoring a Java virtual machine. JConsole can monitor both local and remote JVMs and can be used to monitor and manage JMX applications.
Typically, the work flow of implementing and executing manageable applications is as follows:
After you install the JMX and JConsole plugins you will see that the following buttons are added to the toolbar. The actions are also accessible under the Debug menu item in the main menu.
|Run Main Project with Monitoring and Management|
|Debug Main Project with Monitoring and Management|
|Start JConsole Management Console|
Note. JConsole is part of the Java Platform and can be used independently from the IDE. For details, refer to the following resources.
The JMX module includes a sample application with JMX monitoring built into it.
Clicking this button launches and displays the Anagram Game:
The JConsole window is also displayed.
This document was a short and quick introduction to the JMX module for NetBeans IDE. For more detailed information, see the following JMX module tutorial: