Monday, September 8, 2008

Setting up Sun's VisualVM on Mac OSX

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.

4 comments:

Leszek GruchaƂa said...

Thanks!

Simao M said...

I updated with the last update from http://developer.apple.com/java/download/ but it seems `visualvm` is not included in my path. Where is it? Any idea? Thanks.

Matthew McCullough said...

Simao, on Mac, it still doesn't ship with the JDK like it does on Windows. You need to download it separately from https://visualvm.dev.java.net/and put in in your PATH.

Simao M said...

Oh, ok thanks :)