EasyMX - An alternative to JMX

DZone 's Guide to

EasyMX - An alternative to JMX

· Java Zone ·
Free Resource

Monitoring and getting information about the internals of application is always crucial. For this reason Java platform has introduced JMX infrastructure long time ago.
It allows you to access detailed information about the application in a standard way. Here, I'll show you another way of getting and displaying the details about the application. I prefer this way as it seems to be easier to use than JMX. I have opened a project called "EasyMX" in SourceForge, you can access codes at

EasyMX uses Rest and Eclipse plugins. The management services are developed using Rest and accessed by the Eclipse plugin. I will explain it step by step below. First you have to write a service to get information about the application, say it is a time service displaying current server time. You have to configure Rest first.

in web.xml, add a servlet to configure Rest;

		<servlet-name>Jersey REST Service</servlet-name>

		<servlet-name>Jersey REST Service</servlet-name>


It accepts all Rest implementations under the package "net.sourceforge.easymx.web.rest"

Second add an class, e.g SysInfo, under this package and write a service to get current time of the server;

public class SysInfo {
	public String getTime() {
		return new Date().toString();


Make sure that you can see time information by browsing to http://localhost:8080/easymx/rest/sysInfo/getTime. You should see something like this : Fri Nov 25 17:13:47 EET 2011
Now, the time service completed and you can see it using the Eclipse plugin also.

EasyMx has an Eclipse plugin which you can install just like other plugins by copying it to plugins folder of Eclipse install path. After copying and restarting the
Eclipse, choose EasyMX/Servers List from "Show View" menu item. You should see similar screen as below;


First thing you have to do is to add an server. To do that, right click on "EasyMX Servers" node and click "Add server". You should enter server name and uri of
rest services. In this example you should enter;
Server name : Test Server
Address        : http://localhost:8080/easymx/rest

Click "Ok" and server definition is added. 

Now, you should define services in the plugin to access the service you developed on the server. To add the service, right-click on server "Test Server" and click on "Add service". You should see similiar screen as below;


Service name      : sysInfo
Context URI         : /sysInfo/getTime
Result type          : text

You enter a name for service and uri you can access. Uri must starts with "/" and points to your Rest time service. Since your server address is http://localhost:8080/easymx/rest" and the service uri is "/sysInfo/getTime", complete address of your service is concatenation of these two addresses, "http://localhost:8080/easymx/rest/sysInfo/getTime". You set "text" as result type as you just return a simple string from time service. It can be "tabular" also, I will show the usage of that result type later.

To invoke the service, double click on the service name and a dialog screen is displayed. First part of the dialog allows entering parameters of the service. For this service, there is no need to enter any parameter so this part is empty. Second part is includes  button to invoke the service and an area to show the status of service invocation. Just click on "Invoke service" button, you should see server time;


Second service lists the properties of a Java application. The service implementation;

	public String getSysProps() {
		Properties props = System.getProperties();
		List<Map<String,String>> propsNormalized = new ArrayList<Map<String,String>>();
		for(Map.Entry<Object, Object> entry:props.entrySet()) {
			Map<String, String> val  = new HashMap<String, String>();
			String name = "";
			if( entry.getKey() != null ) {
				name = entry.getKey().toString();
			String value = "";
			if ( entry.getValue() != null) {
				value = entry.getValue().toString();
			val.put("name", name);
			val.put("value", value);
		Collections.sort(propsNormalized, new Comparator<Map<String, String>>() {
			public int compare(Map<String, String> o1, Map<String, String> o2) {
				return o1.get("name").compareTo(o2.get("name"));
		return new EasyMxUtil().generateXml(propsNormalized, "name", "value");

 This service lists the properties and its values in a tabular format. Data is received in xml format conforming the standard below;

	<row> <propertyName value="propertyValue"/>  </row>

EasyMxUtil class is used to generate the xml format. You don't need to use that class, generating xml data in proper format is enough.
Now it comes to defining this new service in the plugin. Right-click on the server and click on "Add service". Add the values below;

Service name : sysInfo-getSysProps
Context URI    : /sysInfo/getSysProps
Result type     : tabular

Since the data is in xml format you should set the result type as "tabular". When you click on "Invoke service" the similar screen like below displayed;

You can see the properties and values of you service result as listed tabularly. You can also view the raw xml formatted data returned. If you click any
cell of the table you see it is copied to area below.

Another feature of the plugin is passing parameters to the service. To give an example for this, a service to search a property by name is developed.

Service implementation;

	public String getSysPropByName(@QueryParam("name") String name) {
		if ( name == null ) {
			return "";
		Properties props = System.getProperties();
		return props.getProperty(name);

Service definition in plugin;

Service name : sysInfo-getSysProps
Context URI    : /sysInfo/getSysPropByName
Result type     : text


You can add parameters by right-clicking on parameters(name-value pairs) area and selecting "Insert New Property". Enter "name" as name field, and "user.home" as value.

You should see similar screen;


All information related to the servers and services is stored in file ".easymx-servers.xml" under user home folder.

 Another screenshot listing the services;


There are some drawbacks of using this approach. First it has no notification mechanism as in JMX and no security issues considered. But it may be a different way of accessing detailed information about your application. You can download files from https://sourceforge.net/projects/easymx/files/1.0.0/




Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}