Setting up Sun's VisualVM on Mac OSX

09 Sep 2008

There is a relatively new tool out from Sun call the VisualVM. It is, in short a super new version of JConsole. In fact, it even runs all the extensions you have previously written for JConsole. Nice job Sun! You can profile, take snapshots, and watch in real time, threads, memory usage, and so much more of any local or remote java application.

Now, it takes a little bit of a trick to get it to work on Mac OSX. You need the latest Java 6 JDK installed, though it can monitor apps running on JRE 1.4 through JRE 7.0. But if you don't set it as your default JDK, which can cause many apps such as Eclipse and CyberDuck to stop working, then you'll need to use the --jdkhome option when launching visualvm. I set up a shell script to do so. The full invocation is as follows:

visualvm --jdkhome /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/

There is even a getting started guide that shows you the basic features. And if video is more your style, there's a vodcast that shows off this new app as well. If you still can't get enough of this new tool, there's a neat DZone overview written by Geertjan Wielenga.