问题
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
回答1:
visualvm checks the following three directories for a JDK:
/usr/lib/jvm/java-7-openjdk-$ARCH/usr/lib/jvm/java-8-openjdk-$ARCHand/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
回答2:
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
来源:https://stackoverflow.com/questions/34566176/visualvm-fails-with-no-jdkhome-found-on-ubuntu-15-10-with-oracle-jdk