It’s hard to put a label on VisualVM – it has a profiler, but it’s more than that. It also has tools for tracking threads, interacting with garbage collection, and monitoring memory and CPU usage. We use it to help development of our products BuildVu, FormVu, JPedal, and JDeli.
What you might not realise is that you almost certainly have VisualVM installed – it’s been included as a standard part of the JDK since Java 1.6 update 7. Further to this, it’s actually an evolution of Netbeans’s profiler, which was first introduced in 2004.
All of the major IDEs used by Java developers – with the exception of Netbeans due to its integrated profiler – can quickly be set up to use VisualVM. So here’s how to do it for IDEA and Eclipse.
To set up VisualVM in Idea, first download the VisualVM Launcher jar. Open up the plugins settings page and install it by selecting ‘Install plugin from disk’.
Relaunch Idea and go to the new VisualVM Launcher settings page. Set the path to your jvisualvm.jar file which should be in your JDK’s bin folder.
Idea will now have buttons for launching or debugging with VisualVM.
Download the VisualVM launcher for Eclipse and extract it to a location of your choosing. Launch Eclipse and click ‘Help’ -> ‘Install New Software…’.
Click ‘Add..’, fill in a name and then click ‘Local’. Find your VisualVM launcher folder and select it.
If you now return to the Install Software dialog you should see the launcher feature available to install. Select it and hit Next. Follow the instructions on screen and Eclipse will restart.
Navigate to VisualVM Configuration in Preferences where you can set your JDK (make sure it is not the JRE) and then set the executable to the jvisualvm.exe in your JDK’s bin folder.
If you now go to Default Launchers in the same location, you can set Run and Debug configurations for your Java Application. Edit one or both to have the preferred launcher as VisualVM.
Now run your application and you’re good to go!
Note: If your application executes and ends extremely quickly, VisualVM might not pick it up in time. If this is the case, you can set a breakpoint in your code and run it in debug mode. This will allow VisualVM to recognise it and you can proceed to run it as normal.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Do you need to solve any of these problems?
|Display PDF documents in a Web app|
|Use PDF Forms in a web browser|
|Convert PDF Documents to an image|
|Work with PDF Documents in Java|
13 Replies to “Setting up VisualVM in under 5 minutes”
The first step did not work… It is a JetBrains plugin so no download of the jar is necessary nor is the load from disk. Just go to settings and select ‘Install JetBrains Plugin…’ and select VisualVM from list.
Will not work in Eclipse JUNO unless installed in the eclipse/plugins directory
I am using Eclipse IDE and getting the following error when I am launching the java application using Visual VM:
An internal error occurred during: “Launching TestNew”.
“TestNew” is the name of the class with main method I am trying to execute.
Same problem here:
An internal error occurred during: “Launching Test”.
Version: Juno Service Release 2
Build id: 20130225-0426
Turned out I didn’t have visualvm on my system, downloaded it at: http://visualvm.java.net/download.html
Then set the Window=>Preferences=>Run/Debug=>Launching=>VisualVM configuration=> exe path correctly
Hope this helps someone else 🙂
Thanks so much Yo!!!
thanks your good post..
Run and Debug with VisualVM options have appeared in my Run menu, but they’re grayed out.
Hey Chad. Are your other run options (Run and Debug) greyed out too? If that’s the case then it could be that either a main method doesn’t exist or run configurations are not set.
I actually *just* figured this one out, but thanks for the prompt response! For some reason the options are only available when I’m selecting my SpringBoot run configuration, but they’re grayed out with the local Tomcat version. Not a big deal, as the issue I’m debugging is repeatable in both. Thanks for making this blog post!
I am trying to use Visualvm with intelj. I installed it from martkeplace. i restarted id. During run time, it is asking for Visualvm executable path. I have searched through jdk bin folder but couldn’t find .exe file for visualvm. Any ideas?
Comments are closed.