Advertise with us

Our eBooks

Monitor JBoss AS with Jolokia


Pretty nice. One thing you might need is interacting with the AS MBeans programmatically. There are several options for it (including Javascript). We will use a plain Java Client. In order to use the Jolokia Java API, you need to donwload a few libraries:

Jolokia Client API

And the following dependencies:

So, once downloaded all the required libs, in the following example we will create a minimal Java client which issue a read request on the  HeapMemoryUsage object:

package com.sample;

import org.jolokia.client.*;
import org.jolokia.client.request.*;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class JmxClient {

   public static void main(String[] args) throws Exception {
       J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia/");
       J4pReadRequest req = new J4pReadRequest("java.lang:type=Memory",
       J4pReadResponse resp = j4pClient.execute(req);
       Map vals = resp.getValue();
       Set set = vals.keySet();
       Iterator i = set.iterator();
       while (i.hasNext()) {
           Object key =;
           System.out.println(key + " = " +vals.get(key));


which will produce:

© 2021 All Rights Reserved.

Please publish modules in offcanvas position.