jconsole

I still hate Java, but I do have to say that J2SE “5” is a much needed improvement. Ahh, generics, where have you been all this time? This week I’ve been rewriting an old buggy, crufty server we had sitting around (before: 5000 lines of code, after: 600) and discovered one of the neatest new whizbang features: jconsole, a standalone JVM monitor and JMX console. If you’ve used JBoss’ jmx-console webapp before, it’s the same idea, just prettier.

All you have to do to use it is add -Dcom.sun.management.jmxremote to the java command line, and then run jconsole. Then you can monitor memory usage, get live stack traces on all the running threads, and get general VM statistics. If you create an MBean interface and implementation and register it with the platform MBean server, then you can interact with the application just as if deployed in a JMX container. For example, I have MBean methods to make the server enter and leave maintenance mode for software upgrades. To use them, we just connect with jconsole and click the proper button. Neat.