What is JMX?

... recently I had to answer to this question on the SDN JMX forum. Since it is quite a recurrent question I decided to turn this into a blog. And to spice it a little more, I'm even going to allude to some of what JMX(tm) - Java Management Extensions - is not ...

What is JMX?

To make it short, JMX is a technology that lets you implement management interfaces for Java applications.

A management interface, as defined by JMX, is composed of named objects - called MBeans (Management Beans). MBeans are registered with a name (an ObjectName) in an MBeanServer. To manage (a) resource(s) in your application, you will write an MBean that defines its management interface, and then register that MBean in your MBeanServer.
The content of the MBeanServer can then be exposed through various protocols, implemented by protocol connectors, or protocol adaptors.

A protocol connector (e.g. the JMX RMI Connector) exposes the MBeans as they are - so a remote client sees the same model than a local client.
A protocol adaptor (e.g. an SNMP adaptor, or HTML adaptor) performs (or provides hooks to let you perform) a model mediation - to adapt the model to what a client of that protocol (e.g. SNMP Manager, or Web Browser) would expect to see.

Today there is one standard connector defined for JMX - which is the RMI Connector, and comes in two flavors: RMI/JRMP and RMI/IIOP. There's also a JMX WebServices Connector in the making - which is being defined by JSR 262.

There are also a number of non-standard connectors and adaptors, either free or commercial, that have been implemented by the community.

A good place to start learning about JMX is the Trail: Java Management Extensions (JMX) from the online Java Tutorials.
More on JMX: Looking for JMX Overview, Examples, and More...

Are there examples of concrete and real situations where JMX has been used, and how?

You will find more on tools/products using JMX on the JMX Home Page.

But among other things, JMX is used today to manage the JVM itself. It is also widely used in the management of application servers.

See also:

Using JConsole to Monitor Applications
Mandy Chung's Blog - lots of articles on JVM management.
Understanding JMX Technology
Getting Started with Java Management Extensions (JMX): Developing Management and Monitoring Solutions
GlassFish Project - AMX (Appserver Management EXtensions) home page
Managing and Monitoring Web Services in Project GlassFish
Using Custom MBeans to Extend the GlassFish Administration System
Managing OpenDS with JMX and JConsole

... and also somewhat more adventurous applications!

What is the difference between MBeans and EJBs?

An EJB lives in an Application Server container. It usually implements business logic. An MBean lives in an MBeanServer, and usually implements management logic (configuration, monitoring, etc)...

See the comments below for a little more flesh ;-)

Note also that JMX is a J2SE technology - it's now part of the JDK - and can be use to manage and monitor both J2EE applications and plain J2SE applications.

Got more questions?

Maybe you'll find your answer in some of these few other interesting places.

What JMX is not...

Well now that we have gone through what JMX is, let's see some examples of what JMX(tm) (Java Management Extensions) is not:

... and probably still much more!


-- daniel

I think your EJB differentiator could need some more flesh: Is JMX(remote) a distributed object system? What is it that differentiates JMX from such? Where do you draw the line between remote application access and management? I find these guidelines underrepresented in the discussion.

Posted by Matthias Ernst on September 29, 2006 at 05:57 AM CEST #

Hi Matthias,

Yes you are right, they are under represented, maybe because I'm not a J2EE expert ;-) - so I've sticked to the bare bones: the difference between the business logic - the service itself implemented/provided by an application, and the management logic - the management of that service/application.

The classic example we usually take here is that of a cache - which would offer methods to put data in the cache and get cached data from the cache.
Accessing cached data, putting data in the cache, etc... is in that example the business logic of the cache.
Configuring the capacity of the cache, monitoring its current occupation ratio, firing notifications if it overflows, and resizing the cache capacity would constitute its management logic.

This is where I would draw the line.

Assuming you have done the work to categorize what is business logic and what is management logic in your application, you will use EJBs to implement/expose your business logic, and you will use MBeans to implement/expose the management logic.

Of course the EJBs and MBeans will need to conspire behind the scene - so that the MBeans can get data or tweak the behavior of the managed resources, or so that the EJBs can update/refresh the states/data reported by the MBeans.

Eamonn did a very interesting talk on this subject (linking MBeans with Managed Resources) at last Java One.

I don't know whether you can say that JMX is a distributed object system (= I believe it's not), but you will be able to use JMX to implement distributed management solutions, should you choose to do so.
One of the features discussed for JSR 255 (JMX 2.0) is precisely federation of MBeans/MBeanServers which should ease such implementations.

Thanks for your feedback!

-- daniel

Posted by daniel on September 29, 2006 at 08:14 AM CEST #

On differentiator between EJB, MBean : You can say that one of the protocol connectors for an MBean Server can be a EJB. http://java.sun.com/j2ee/1.4/docs/api/javax/management/j2ee/ManagementHome.html I agree with you on core differentiator of EJB=Biz logic, MBean=Management Logic.

Posted by Prashant on October 03, 2006 at 02:22 AM CEST #

There's some followup questions to be asked. What is inherently "management" that explains why JMX needed to define its own "Bean" abstraction, its own definition of "attribute" and "operation" instead of simply building on the Java bean concept? Why wouldn't one simply use POJOs and some remoting protocol? Interestingly, JMX shines because JMXRemote + Jconsole make it super simple to display some stats but -conceptually- how is "management" different that it warrants such a specification?

Posted by Matthias on October 03, 2006 at 01:22 PM CEST #

Hi, Why not use only RMI for distributed application? When is need use JMX over RMI?

Posted by Yeray Santana Borges on November 03, 2006 at 03:12 AM CET #

See the followup here: Easy Is Not Always Simple. cheers, -- daniel [8+50=58]

Posted by Daniel on November 09, 2006 at 07:56 AM CET #

Differences between SNMP and JMX

Posted by K.Rajasekaran on August 21, 2007 at 07:54 AM CEST #

Hi K.Rajasekaran,

Please see:
JVM Monitoring: JMX or SNMP? on this subject!

-- daniel

Posted by guest on August 27, 2007 at 03:00 AM CEST #

Hello, Daniel! I write you without any reason. Well... I have a reason. I wanna thank you. Everything you write here and at the http://forum.java.sun.com is very very very helpful. I don't know what would I do without you! There is not enough information on JMX for me. But with your help I survived! Thank you so much!

Posted by Alina on September 10, 2007 at 05:22 AM CEST #


I'm not very skilled in Java. I wat to ask. I have two war applications on my server. And I want that one war app can use seevices of second. I use rmi services. Is any better way to make it? is JMX suitable for such thing?


Posted by modrofuz on October 03, 2007 at 08:42 AM CEST #

hi daniel
this is good blog as we got some information regarding jmx

Posted by abcd on May 24, 2008 at 12:31 AM CEST #


I have seen use in commercial projects(im being ambigous for subtle reasons) they use jmx and rmi(provided by spring framework) to achieve single point of access for business classes. The portlets access the business logic classes using request passed to jmx server. The request happens when the portlets are initialized. I mostly havent done much of my homework to find out why? Although would appreciate any inputs.Thanks.

Posted by Pawan on September 05, 2008 at 01:03 PM CEST #

Essentially the question is whether jmx can be used to access a business class as is,because we are getting the same functionality that of EJBs(the spring bean is being registered with a jmx server as an mbean,and the portlets are requesting the bean from the jmx server). The process of requesting the mbean is also happening using spring initialization that happens when the spring portlet initializes.This essentially is a very good substitute for using EJB.

Posted by Pawan on September 05, 2008 at 01:13 PM CEST #

Daniel!you are given the information regarding http://forum.java.sun.com is very useful for me
Thank you so much!

Posted by Sportswear on November 05, 2008 at 03:10 AM CET #


Posted by guest on February 25, 2009 at 09:50 PM CET #

Post a Comment:
Comments are closed for this entry.

Daniel Fuchs blogs on Scene Builder, JMX, SNMP, Java, etc...

The views expressed on this blog are those of the author and do not necessarily reflect the views of Oracle.


« July 2016