19

I installed Oracle JDK from the webupd8team/java PPA, and then installed the visualvm package. When starting visualvm, I get the following error message:

[beni:~]$ visualvm
No jdkhome found

My $JAVA_HOME is set correctly to /usr/lib/jvm/java-7-oracle.

Also, when starting visualvm with the jdkhome property set, I get the same error:

[beni:~]$ visualvm --jdkhome $JAVA_HOME
No jdkhome found
Benedikt Köppel
  • 4,853
  • 4
  • 32
  • 42

2 Answers2

38

visualvm checks the following three directories for a JDK:

  • /usr/lib/jvm/java-7-openjdk-$ARCH
  • /usr/lib/jvm/java-8-openjdk-$ARCH and
  • /usr/lib/jvm/default-java

From the /usr/bin/visualvm start script:

visualvm_jdkhome=
for j in /usr/lib/jvm/java-7-openjdk-$ARCH /usr/lib/jvm/java-8-openjdk-$ARCH /usr/lib/jvm/default-java; do
    if [ -x $j/bin/javac ]; then
       visualvm_jdkhome=$j
       break
    fi
done

So make /usr/lib/jvm/default-java a symlink to $JAVA_HOME, and visualvm will find the right JDK.

cd /usr/lib/jvm
sudo ln -Tsf java-7-oracle default-java
Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
Benedikt Köppel
  • 4,853
  • 4
  • 32
  • 42
  • You need the `-T` and `-f` options of `ln` since the `default-java` symlink probably already exists. I've updated the answer accordingly. Please feel free to revert if you disagree. – Sylvain Leroux Apr 13 '16 at 09:22
  • Thanks Sylvain. Although from my understanding, you only get the `No jdkhome found` error if the `default-java` does not yet exist. – Benedikt Köppel Apr 13 '16 at 09:32
  • 2
    As a matter of fact, I've encountered that exact problem yesterday : on one machine, `default-java` was a symlink to openjdk-7 and `visualvm` refused to start because of that. I wasn't able to find the correct Debian-specific script managing that link (I assume there *is* such a script) -- so I've updated it manually. – Sylvain Leroux Apr 14 '16 at 20:22
  • Ah okay, makes sense. Let's keep it with `ln -Tsf` then. Thanks for your input! – Benedikt Köppel Apr 15 '16 at 13:22
1

In my case even the symlink of default-java didn't fixed the problem. To fix, I did:

Edited jvisualvm and add any "trash" into jdkhome variable

  • $ sudo vi /usr/bin/jvisualvm

jdkhome=/tmp

Then started the program passing parameter:

  • /usr/bin/jvisualvm --jdkhome /usr/lib/jvm/myJava7

Note: today (2016), with my version is working only with java7

Update:now, in 2017, using version 1.3.8, it's working with Java 8. But I needed to add visualvm_jdkhome=/tmp, in /usr/bin/visualvm

Topera
  • 12,223
  • 15
  • 67
  • 104
  • I got "Your are running VisualVM using an unsupported Java version: 1.8." Is this same for the upstream version? – mnish Nov 11 '16 at 06:40