问题
I've installed Eclipse and jdk manually. My JAVA_HOME is set, and I am able to run the java -version and javac -version commands, but when I try to run Eclipse, it shows the following message:
A Java Runtime Environment (JRE) or Java Development Kit (JDK)
must be available in order to run Eclipse. No Java virtual machine
was found after searching the following locations:
/home/$USER/development/eclipse/jre/bin/java
java in your current PATH
How can I fix this?
Distro:
Ubuntu 12.0.4 64 bits.
Java:
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
$JAVA_HOME:
/usr/lib/jvm/jdk1.6.0_45
My $PATH contains the following:
/usr/lib/jvm/jdk1.6.0_45/bin
Thank you for the help
回答1:
If Eclipse isn't finding your JRE/JDK or finding the wrong version, add the following two lines to the begining of your eclipse.ini file:
-vm
[your-path-to-java-executable]
回答2:
Another possible solution is to add your java bin path to your environment variable PATH in /etc/profile file. Something like this
sudo gedit /etc/profile
Go to the end of the file and add this line:
export PATH=$PATH:/path/to/your/jdk/bin/
回答3:
I had some issues with the other solutions, so the following is what I did:
1) Open a terminal window
2) Enter the eclipse sub-directory
cd ~/eclipse
3) Execute: whereis java
4) Pick a jdk path that also has the jre as a sub-directory
I chose: /usr/java/jdk1.8.0_102/bin/java
which has a jre subdir: /usr/java/jdk1.8.0_102/jre
5) Create a symbolic link in the ~/eclipse
sub-directory.
The following is an example:
ln -s /usr/java/jdk1.8.0_102/jre jre
回答4:
Go to your jre path within JDK installation home and copy the jre directory under eclipse installation.
来源:https://stackoverflow.com/questions/16843976/how-to-make-eclipse-to-find-my-jdk-in-linux