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
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]
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/
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
Go to your jre path within JDK installation home and copy the jre directory under eclipse installation.
Folder Structure after download eclipse
open eclipse.ini
add on top
-vm
[your-$JAVA_HOME-path]
ex: /usr/lib/jvm/jdk1.8.0_241/bin
-startup
...
openFile
-vm
/usr/java/jdk1.8.0_251/bin/
-vmargs
...