JMX with Java Tiger (J2SE 5.0)

Java 1.5 now supports the Java Management Extensions (JMX) framework. This allows remote monitoring and management of the JVM. Details such as memory useage and availability are available remotely via JMX, and via SNMP. SNMP (Simple Network Management Protocol) operates over UDP port 161 and is accessed using a Managed Information Base (MIB) browser. More information on SNMP can be found in Network programming in .NET.

Below is an example of monitoring of memory usage via JMX.

import java.lang.management.*;
import java.util.*;
public class MemTest
{     
 public static void main(String args[])
 {
  List<MemoryPoolMXBean> pools = ManagementFactory.getMemoryPoolMXBeans();
  for (MemoryPoolMXBean p: pools) 
  {               
	System.out.println("Memory type="+p.getType()+" Memory usage="+p.getUsage());
  }
 }
}
 

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd