January 6th, 2009

ronin

JConsole - best thing EVER for debugging and monitoring Java apps.




If you're using Java 5 or 6, you need to start the application that you want to monitor while passing an extra flag to the JVM to enable monitoring. Let's assume you want to start MyJavaApp.jar with JMX enabled. If you're launching the application from the command line, simply add -Dcom.sun.management.jmxremote=true after the java command, like this:

java -Dcom.sun.management.jmxremote=true -jar MyJavaApp.jar

JConsole comes with the JDK (but not the JRE) and can be found in the %JDK_HOME%/bin directory. To launch JConsole, open a terminal or command window, change to the directory containing it, and execute jconsole. When JConsole starts, it shows a window listing the managed Java VMs on the machine. The process id (pid) and command line arguments for each Java VM are displayed. Select one of the Java VMs, and JConsole attaches to it.


http://www.builderau.com.au/program/java/soa/Monitor-and-manage-Java-applications-with-JConsole/0,339024620,339290055,00.htm

Tracks memory usage, shows heap and threads, can even monitor Java code running on other machines!