Monitoring and Managing JMX Instrumented Java Web Start Applications with JConsole

In a previous blog entry I wrote about Monitoring and Managing JMX Instrumented Applets with JConsole. In this new blog entry I would like to show the same thing but for Java Web Start applications instead of Java applets.

I will show here how Java Web Start applications can be instrumented using JMX, launched from a web browser by clicking on a link and monitored and managed using Mustang JConsole.

The following steps will take you through an example that shows all the necessary implementation and configuration steps required to achieve this.

NOTE: I have successfully run this example on Firefox version and Internet Explorer version 6.0 with the latest Mustang binary snapshot.

Instrumenting the Java Web Start application

Java Web Start is a mechanism for program delivery through a standard web server. What I call here a Java Web Start application is simply a Java application that is deployed using Java Web Start. I have implemented a very simple Java Swing application that I will launch with Java Web Start named InstrumentedJWS. The application displays a label with a string message in a frame. I have created a Standard MBean named LabelInfoMBean that exposes for management some of the label's properties such as the Text, ToolTipText, Height and Width. When the application's main method is called the application creates an ObjectName for the label resource and registers its associated LabelInfo MBean in the Platform MBean Server. When the frame window containing the label is closed the label's associated LabelInfo MBean is unregistered from the Platform MBean Server.

Let's have a look at the source code:

public interface LabelInfoMBean {
    public String getText();
    public String getToolTipText();
    public int getHeight();
    public int getWidth();

public class LabelInfo implements LabelInfoMBean {
    private JLabel label;
    public LabelInfo(JLabel label) {
        this.label = label;
    public String getText() {
        return label.getText();
    public String getToolTipText() {
        return label.getToolTipText();
    public int getHeight() {
        return label.getHeight();
    public int getWidth() {
        return label.getWidth();

public class InstrumentedJWS extends JPanel {
    private MBeanServer mbs;
    private ObjectName name;
    private JLabel label;
    public InstrumentedJWS() {
        label = new JLabel("This is an example of a JMX instrumented JWS app");
        label.setToolTipText("This is the label's tooltip");
    private void init() {
        try {
            mbs = ManagementFactory.getPlatformMBeanServer();
            name = ObjectName.getInstance("com.example.jws:type=InstrumentedJWS");
            mbs.registerMBean(new LabelInfo(label), name);
        } catch (Exception e) {
            System.err.println("Error in init method");
    private void destroy() {
        try {
        } catch (Exception e) {
            System.err.println("Error in destroy method");
    public static void main(String[] args) {
        final InstrumentedJWS app = new InstrumentedJWS();
        JFrame frame = new JFrame("JMX instrumented JWS app");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
        frame.getContentPane().add(app, BorderLayout.CENTER);

Signing the application's jar file

Compile the source files above and create the InstrumentedJWS.jar jar file. Retrieving the reference to the Platform MBean Server requires Java permissions so the jar file needs to be signed.

For testing purposes I would recommend you to use self-signed certificates to sign the jar file in order to avoid the hassle of going through a Certification Authority (CA).

The Java Web Start application JNLP file

JNLP stands for Java Network Launching Protocol. The JNLP file is an XML document describing how the application is to be deployed by Java Web Start.


<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="" href="InstrumentedJWS.jnlp">
    <title>JMX Instrumented Java Web Start Application</title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <j2se version="1.6+"/>
    <jar href="InstrumentedJWS.jar"/>
  <application-desc main-class="com.example.jws.InstrumentedJWS"/>

Applications can be deployed from any standard web server. In order to use Java Web Start, the web server must be configured with support for a new MIME type. You will have to configure your web server before deploying the application so that all files with the .jnlp file extension are set to the application/x-java-jnlp-file MIME type.

The Java Web Start application HTML file

In order for an application to be launched from a web page via JNLP, the page must include a link to the JNLP file.


    <a href="">Launch the application</a>

Deploy the Java Web Start application in a web server which supports the JNLP MIME type

I have used the web server to deploy the Java Web Start application, i.e. I have uploaded to the website the InstrumentedJWS.html, InstrumentedJWS.jnlp and InstrumentedJWS.jar files.

Click here to load the web page containing the link to the Java Web Start application.

Link to Application Launcher

The web browser will pop up a window asking you if you want to open the JNLP file with the Java Web Start Launcher. Press the OK button to start the application.

Open JNLP file

As I used a self-signed certificate to sign the application's jar file it is likely that the Java Web Start Launcher will pop up a window where you will have to explicitly trust the certificate before running the application.

Trust the application's digital signature

As soon as the application is started the Swing frame with its associated label is instantiated and a new LabelInfo MBean is created and registered in the Platform MBean Server.

Once the application is started you should see something like this:

JMX instrumented JWS started

Run the Java Control Panel, go to the General tab and click on the View button in the Temporary Internet Files. Look at the Java Cache Viewer and verify that your application has been downloaded and stored in the viewer's cache.

Java Cache Viewer

Run Mustang JConsole and connect to the Java Web Start JVM

Run Mustang JConsole in the same machine where the application is running as follows:

% jconsole

Select the PID starting with the name com.sun.javaws.Main ... in the Connection dialog. This PID corresponds to the Java Web Start JVM where the application is running. Press the Connect button to enable the management agent in the Java Web Start JVM and connect to it.

Connection dialog: select PID for web browser's JVM

Go to the MBeans tab and you will see the application's LabelInfo MBean and its attributes showing the label's text, tool tip text, height and width.

LabalInfo MBean

Summing up, I hope you have encountered this example useful although I know the JMX instrumentation implemented in this Java Web Start application might be useless from a management standpoint but the aim of this example is not to show what is the useful or meaningful information an application which is launched with Java Web Start should expose for management (I let this job to real application developers) but how an application can be instrumented using JMX, registered in the Platform MBean Server and monitored and managed using JConsole just by writing a few lines of code.

Feel free to download the resource zip file in attachment and play with it or tailor it to your specific application needs.


Hi, I've tried this approach on both Java 1.5 and Java 1.6. No matter what I do, I cannot get the Local java processes listing to appear. I can use the and connect to a "remote" process that way. But local java processes do not appear from jconsole or from jps.

Posted by Perry Nguyen on December 11, 2006 at 01:23 PM CET #

Works well with local connections. I tried a remote connection, setting <property name="" value="1090"/> <property name="" value="false"/> <property name="" value="false"/> in the JNLP file, but I got an connection refused error in JConsole. Could this be an security problem?

Posted by Stefan Nickisch on January 05, 2007 at 02:44 AM CET #

Hi Stefan,

Have a look at the following java developer forum thread on that subject:

Setting a system property real early


Posted by Luis-Miguel Alventosa on January 10, 2007 at 09:40 AM CET #


I've tried run JCOnsole as Java WebStart Application
with JConsole Plugin JTop provided by JDK 1.6.[all jars - signed] - but it don't works.

Do you have an solution.

Posted by thomas merten on January 04, 2009 at 10:27 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed



« July 2016