Getting started with jconsole just got easier!

J2SETM 5.0 brought some great monitoring and management capabilites to the JavaTM platform. The built-in instrumentation in the Java Virtual Machine means you can monitor and manage it using JMX. And of course, if the application have been instrumented with JMX then it gets even better. As part of the monitoring and management implementation a JMX-compliant monitoring tool called jconsole was developed. I hope you have tried it. If you haven't tried it let then a good starting place is the this page on Monitoring and Management Using JMX

One of the goals during the development of jconsole was that it should be easy to get going very quickly. The JMX agent has lots of configuration properties but a new user should be able to avoid most of this and get going in a few simple steps. All you need is to start the application with a simple property on the command line. When this property is set then the JMX agent starts up in a way that allows jconsole to connect without needing to prompt for connection details. This is somethings called local monitoring because it restricts the monitoring to the local machine (you have to be the same user too). The property is so you start your application like this:

java App

Once the application is running then jconsole can connect. If you know the process-id (pid) then "jconsole <process-id>" should do it. Alternatively, if you don't know the process id then start jconsole without any parameters and select the application in the connection dialog.

It turns out that it gets even simpler in Mustang (Java SE 6.0). The reason is that jconsole has been updated so that it can connect to applications that did not start up with the JMX agent. This is rather useful as it allows jconsole to connect to applets in the browser, Java Web Start applications, and other applications where it isn't easy to fiddle with the command line.

So how does it work? jconsole uses a JMXConnector client to connect to the JMXConnectorServer in the target application. In the application isn't started with the JMX agent then there isn't a JMXConnectorServer and jconsole doesn't have anything to connect too. In that case it uses a HotSpotTM VM specific mechanism to start the JMX agent in the target VM. Once the agent is started then jconsole connects as normal.

This sounds very cool so let us see how it looks. First, we start jconsole. I haven't use any parameters so jconsole opens the Connection Dialog. I've selected the Local Tab and jconsole shows me the applications that I have running on this machine. In this screen-shot I have clicked ona Java Web Start application called bugster:

Next I press the Connect button. Behind the scenes the JMX agent is started in the target VM and jconsole connects. (By the way, that checkbox column with the title Enabled just indictaes if the JMX agent is running in the target VM or not - this is probably not the best way to indicate this but jconsole is due a new connection dialog soon and it should look much better). Once the connection is established jconsole opens up Summary Tab which gives me a summary of the bugster application.

I'm sure you'll agree this is rather neat and makes getting started with jconsole very easy.


[Trackback] The Tiger JDK introduced a nifty feature whereby you could run an application with and then later connect to it using the jconsole tool. That allows you to see the JVM's instrumentation (memory, classes, threads) plus an...

Posted by Eamonn McManus's Blog on September 29, 2005 at 02:32 AM PDT #

Hi, Does this have any ugly security connotations, ie allowing script kiddies to poke around inside apps they aren't running or that they are trying to break or reverse engineer? Rgds DamonHD

Posted by Damon Hart-Davis on September 29, 2005 at 11:27 PM PDT #

The operating system security isn't bypassed if that's what you mean. Also, you can't do anything that you wouldn't be able to do when logged into the system. In Solaris/Linux this essentially means you need to have the same effective uid/gid as the target process. On Windows it seems to have to privileges to open the target process. So if script kiddie is on your machine then he gets to poke around in his own applications but not yours.

Posted by Alan Bateman on September 30, 2005 at 12:36 AM PDT #

good infor

Posted by guest on June 22, 2006 at 03:52 AM PDT #

This is great management tool... however I am trying to get JConsole to connect to JDK 1.4 application... someone told me they did it (but they are not around now) but some Documentation seems to imply you cannot connect and some does, but in any case I cant :-)

Posted by Mike on June 30, 2006 at 01:01 AM PDT #

Mike - for 1.4 you'll need to download the JSR-160 RI from: You'll also need to some code in the application to start a JMX connector server and a local RMI registry. Once you've that then you can connect via jconsole by specifying the connection details in the remote tab.

Posted by Alan on July 11, 2006 at 06:13 PM PDT #

the jmx tutorials talk about using rmi registry (so one needs to start rmiregitry) so one app (say some mgmt console) can control another app, but jconsole does this without needing the rmiregistry to be started (I think). How does that work ?

Posted by antony sequeira on October 18, 2006 at 11:51 AM PDT #

I Thınk Such Knowledge see The Interest.. thanks.!

Posted by general new on September 27, 2007 at 08:45 PM PDT #


Posted by new on September 27, 2007 at 08:45 PM PDT #

I Thınk Such Knowledge see The Interest.. thanks.!

Posted by antivirus on September 27, 2007 at 08:46 PM PDT #

thank you all

Posted by mp3 on September 27, 2007 at 08:46 PM PDT #

Post a Comment:
Comments are closed for this entry.



Top Tags
« April 2014

No bookmarks in folder