Visualvm java not found

Как запустить VisualVM на MacOS с Java 11

Если вы скачали VisualVM, но на вашем компьютере установлена Java 11, то скорее всего вам не получится запустить VisualVm. Чтобы это сделать, необходимо сделать следующее.

Как запустить VisualVm

Открыть первый раз VisualVm, он у вас скорее всего не откроется, но это нормально. Далее необходимо найти файл visualvm.conf. Для этого откройте Finder, зайдите в Applications, найдите VisualVm, кликните правой кнопкой и нажмите Show Package Contents, далее перейдите в папку ⁨Contents⁩ — ⁨Resources⁩ — ⁨visualvm — etc, там будет файл visualvm.conf. Откройте его в любом редакторе, прокрутите вниз и найдите текст:

Default location of JDK: It can be overridden on command line by using --jdkhome Be careful when changing jdkhome. There are two VisualVM launchers for Windows (32-bit and 64-bit) and installer points to one of those in the VisualVM application shortcut based on the Java version selected at installation time.Code language: Bash (bash)

Далее, если у вас установлена только Java 11, необходимо скачать Java 8, например с сайта oracle. Необходимо будет распаковать java в любую папку, например:

Далее, надо будет просто вставить в visualvm.conf строку:

visualvm_jdkhome="/home/denis/java8"Code language: JavaScript (javascript)

Теперь осталось только сохранить файл и запустить VisualVm.

Источник

visualvm fails to launch because it can’t find jdk: «Cannot find java. Please use the —jdkhome switch»

On a default installation of Ubuntu 10.10 the OpenJava JRE is installed. Install the Sun JDK from the Ubuntu repositories and the Java monitoring tool VisualVM is bundled with it. VisualVM requires a JDK and does not work with a JRE installation of Java. The launch script for VisualVM (/usr/bin/ jvisualvm) contains a line that checks for a JDK,

Читайте также:  Java security nosuchalgorithmexception error constructing implementation

line 13: for j in /usr/lib/ jvm/java- 6-openjdk /usr/lib/ jvm/java- 6-sun; do

This line fails to find the Sun JDK but instead attempts to launch VisualVM using the OpenJava JRE. VisualVM fails to launch and presents a popup dialog asking for a valid JDK.

By switching the order of the «Sun» and «Open» paths in line 13 the problem is fixed and VisualVM loads correctly.

for j in /usr/lib/ jvm/java- 6-sun /usr/lib/ jvm/java- 6-openjdk; do

The Ubuntu package is: visualvm version 1.3-0ubuntu2

I can confirm that I had the same issue on 10.10 and using the above solution worked.

I had the same issue on Ubuntu 10.04, and although the launch script is written differently — the word «sun» does not appear in the 10.04 launch script — the symptom was the same. Attempting to run jvisualvm caused:
[[
$ jvisualvm
Cannot find java. Please use the —jdkhome switch.
]]

The problem seems to be that jvisualvm is a symbolic link into the openjdk directory instead of the Sun JDK directory:
[[
$ which jvisualvm
/usr/bin/jvisualvm
$ ls -l /usr/bin/jvisualvm
lrwxrwxrwx 1 root root 39 2010-11-27 13:08 /usr/bin/jvisualvm -> ../lib/ jvm/java- 6-openjdk/ bin/jvisualvm
$ ls -l /usr/lib/ jvm/java- 6-openjdk/ bin/jvisualvm
-rwxr-xr-x 1 root root 2749 2010-05-03 04:31 /usr/lib/ jvm/java- 6-openjdk/ bin/jvisualvm
]]

However, I do have the Sun jdk properly installed:
[[
$ which java
/usr/bin/java
$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2010-11-23 08:58 /usr/bin/java -> /etc/alternativ es/java
$ ls -l /etc/alternativ es/java
lrwxrwxrwx 1 root root 36 2010-11-23 08:58 /etc/alternativ es/java -> /usr/lib/ jvm/java- 6-sun/jre/ bin/java
$ ls -l /usr/lib/ jvm/java- 6-sun/jre/ bin/java
-rwxr-xr-x 1 root root 47308 2010-09-15 04:41 /usr/lib/ jvm/java- 6-sun/jre/ bin/java
$ java -version
java version «1.6.0_22»
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
]]

My workaround was to explicitly use the —jdkhome option to explicitly specify the Sun JDK directory every time I run jvisualvm:

$ jvisualvm —jdkhome /usr/lib/ jvm/java- 6-sun/

P.S. I also added the actual error message «Cannot find java. Please use the —jdkhome switch» to the bug title, so that people can find it more easily when searching.

summary: — visualvm fails to launch because it can’t find jdk
+ visualvm fails to launch because it can’t find jdk: «Cannot find java.
+ Please use the —jdkhome switch»

See my comments (and earlier ones from others) in bug #577958.

I suspect that DBooth did an upgrade to Lucid like me. This would mean you’d have the Sun JDK and the Lucid version of the visualvm package which won’t detect the Sun JDK properly if the OpenJDK JDK is not installed (due to the script issues discussed earlier here).

There are actually 3 alternatives:

(i) Switch to the OpenJDK fully. Install the OpenJDK JDK (package default-jdk, which sorts out update-alternatives for you). Then jvisualvm will work OK (you’ll be running the OpenJDK one), but you get the Fluid errors like in bug #577958.

(ii) As specified in bug #577958, you can switch to the proper Sun jvisualvm by running /usr/lib/ jvm/java- 6-sun/bin/ jvisualvm explicitly, or changing the /usr/bin/jvisualvm symlink to permanently point to this.

(iii) Do what DBooth did, which runs the OpenJDK jvisualvm, but with the Sun JDK backend. With this, you get the *same* Fluid error as #577958 (but, as with my comments there, this doesn’t seem to affect the ability to link to running/launched Java apps.).

One possible fix for *this* bug is therefore to ensure that a Sun JDK package ensures that an update-alternatives entry for jvisualvm exists to automatically do (ii) above, so that you’re either running the full Sun suite or the full OpenJDK suite (and built into update- java-alternativ es as well). And then you wouldn’t have to worry about all the checking in the OpenJDK jvisualvm script. Of course, this might not be considered valid if the devs want to allow the case of running the OpenJDK jvisualvm frontend with a Sun JDK backend.

The correct fix depends on a full understanding of how jvisualvm actually works.

The —jdkhome option appears to control only the JVM that VisualVM runs in, not the JVM which it monitors for Java instances. I can run the Sun VisualVM with the Sun JVM as jdkhome, and still see/monitor Java programs launched using OpenJDK. Equally, I can run the Sun VisualVM with the OpenJDK JVM as jdkhome, and monitor Java programs launched using Sun or OpenJDK JVMs.

Is the fact I can monitor both because:

a) OpenJDK, as a ‘fork’ of the Sun JDK, retains run-time compatibility in some way?

b) The VisualVM uses standardised JRE/JDK APIs which all JDKs should support (so I could also view stuff launched using, say, IBM’s JVM)?

I assume (b), which would mean that my suggested fix is ‘correct’, because there is no reason to ever want to run one JDK-supplier’s VisualVM using another supplier’s JVM.

This bug was fixed in the package visualvm — 1.3.2-0ubuntu1

—————
visualvm (1.3.2-0ubuntu1) oneiric; urgency=low

* New upstream version.
* Drop build dependency on libnb-apisuppor t2-java. LP: #832764.
* Fix jdk detection. LP: #657048.
* Update package description. LP: #813165.
— Matthias Klose Thu, 08 Sep 2011 13:38:19 +0200

This bug does not seem to be fixed:

Using Ubuntu 11.10 amd64
Installed packages:
• visualvm 1.3.2-0ubuntu1 from oneiric
• openjdk-7-demo 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
• openjdk-7-doc 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
• openjdk-7-jdk 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
• openjdk-7-jre 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
• openjdk- 7-jre-headless 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
• openjdk-7-jre-lib 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
• openjdk-7-source 7~b147- 2.0-0ubuntu0. 11.10.1 from oneiric-updates
no java 6 installed, no sun java installed

when starting jvisualvm from terminal I get this:
––––––– ––––––– ––––––– –––––
$ jvisualvm
No jdkhome found
––––––– ––––––– ––––––– –––––

the reason is that in /usr/bin/jvisualvm , line 13 the paths for java-6-openjdk and java-6-sun are hard-coded. Without having any java 6 installed jvisualvm can not start.

How about
a) integrating java-7-openjdk
b) using the path of /etc/alternativ es/javac instead/ additionally

I have installed openjdk-7 and openjdk-6 on Ubuntu 12.04 LTS

And have same problem. specifying —jdkhome doesl not help (it looks like this switch is ignored):

$ jvisualvm
No jdkhome found

$ update- java-alternativ es -l
java-1. 6.0-openjdk- i386 1061 /usr/lib/ jvm/java- 1.6.0-openjdk- i386
java-1. 7.0-openjdk- i386 1051 /usr/lib/ jvm/java- 1.7.0-openjdk- i386

$ jvisualvm —jdkhome /usr/lib/ jvm/java- 1.6.0-openjdk- i386
No jdkhome found

$ jvisualvm —jdkhome /usr/lib/ jvm/java- 1.7.0-openjdk- i386
No jdkhome found

The /usr/bin/jvisualvm startup script (around line 13) is looking for: /usr/lib/ jvm/java- 6-openjdk :
sv@ubu:~$ grep -n /usr/lib/jvm /usr/bin/jvisualvm
13:for j in /usr/lib/ jvm/java- 6-openjdk /usr/lib/ jvm/java- 6-sun; do

And, assuming the openjdk-6-jdk package is already installed (sudo apt-get install openjdk-6-jdk), there is no link in /usr/lib/jvm for /usr/lib/ jvm/java- 6-openjdk:
sv@ubu:~$ ls /usr/lib/jvm
java-1. 6.0-openjdk- amd64 java-6- openjdk- amd64 java-6- openjdk- common

#Here’s what worked for us:
So, to match things up and make the program work, simply create a symlink:
sv@ubu:~$ sudo ln -s /usr/lib/ jvm/java- 6-openjdk- amd64 /usr/lib/ jvm/java- 6-openjdk

Note: I am using Ubuntu 12.04 64-bit version, so you may have to adjust your symlink accordingly.

Источник

Оцените статью