Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Java program running in Eclipse to show up in VisualVM

Tags:

java

jvisualvm

I'm trying to use Java VisualVM on Windows 7 64-bit together with Eclipse Kepler and am experiencing the following issue:

I have a Java application running inside Eclipse, but when I open jVisualVM, the only item showing up in the Applications under Local is VisualVM itself.

Is it possible to have my Java application show up as well? Do I need to launch it with some command line parameter to allow VisualVM to connect? Do I need to run it outside of Eclipse?

like image 914
Markus A. Avatar asked Feb 12 '23 21:02

Markus A.


2 Answers

Due to a design peculiarity in the Windows JVM's you need to run JVisualVM in the same kind of JVM as the program you want to connect to (and as the same user)

This mean, use either 32-bit or 64-bit, not one of each.

A simple way to ensure this, is to add the JVM in the JDK installation directory containing the jvisualvm executable you want to use to the JVM's known to Eclipse (in Preferences), and then change the JVM used by your project to the one in the JDK you just added. Now your application should show up in the VisualVM window when launched.

like image 128
Thorbjørn Ravn Andersen Avatar answered Feb 14 '23 11:02

Thorbjørn Ravn Andersen


Have you tried using the VisualVM eclipse launcher ? This will automatically launch visual VM for you.

The only change is when you run your main class in eclipse, is to change the configuration to use the VisualVM launcher like this.

enter image description here

like image 30
dkatzel Avatar answered Feb 14 '23 09:02

dkatzel