Where did jvisualvm go?
JavaMacosJava Problem Overview
I am running Mac OSX Snow Leopard.
I've always updated Java using the regular Software Update features of Mac OSX.
I've used the Java jvisualvm
tool in the past with great success.
This morning I typed jvisualvm
into the command line as I often do. I got the following error:
$ jvisualvm
Unable to locate an executable at "/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/jvisualvm" (-1)
All of the other Java tools (java
, javac
, jps
, etc.) work just fine.
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin
indeed does not contain jvisualvm
(all of a sudden).
/usr/libexec/java_home
yields:
$ /usr/libexec/java_home
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
WTF?
Java Solutions
Solution 1 - Java
Seems like a mixup of links; the /usr/bin/jvisualvm symlink points to something that does not exist (as people pointed out above). Apparently the jvisualvm executable (stub) exists and the way to fix this for now is to execute:
cd /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin
sudo ln -s /System/Library/Java/Support/VisualVM.bundle/Contents/Home/bin/jvisualvm .
This requires sudo privileges and creates the missing symlink, pointing to the VisualVM bundle. No idea why it happened but upgrading to latest XCode 4.5.2 did not fix this for me automatically. I am running MacOS X 10.7.5 and java 1.6.0_37
Solution 2 - Java
It seems the supporting bundle got removed upon update. https://discussions.apple.com/thread/4474992?start=0&tstart=0
Download the bundle to use as a workaround. http://visualvm.java.net/download.html
EDIT:
Use this download link: https://java.net/projects/visualvm/downloads/download/release132/VisualVM_132.dmg
Solution 3 - Java
I downloaded the visualvm (.dmg from java.net) and that works for me on my Mountain Lion.
Solution 4 - Java
For JDK 9+ users
> Starting with JDK 9, Visual VM will not be included with Oracle JDK. Developers who would like to use Visual VM with Oracle JDK 9 or later can get it from the Visual VM open source project site.
Solution 5 - Java
If you are already using NetBeans, another workaround is to use its profiler. In version 7.3:
-
Start the Java application from the command line, desktop or [tag:javawebstart].
-
In NetBeans, choose
Profile > Attach Profiler
. -
Select
Attach to: <external Application>
. -
Specify the desired analysis options.
-
Click the
Attach
button. -
Choose the target application.
Solution 6 - Java
The Visual VM binary path for JDK 1.8 in macOS Mojave is
/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home/bin/jvisualvm
Basically,
/Library/Java/JavaVirtualMachines/<JDK_DIR>/Contents/Home/bin/jvisualvm
Solution 7 - Java
I can only run the .app version of JVisualVM on my mountain lion MBP
open /usr/share/java/Tools/Java\ VisualVM.app
Solution 8 - Java
VisualVM is also available as a standalone application. you can install it from https://visualvm.github.io/download.html
Solution 9 - Java
Sometimes it is very simple... you need to install visualvm via
sudo apt-get install visualvm
For locating the files, use
dpkg -L visualvm