Eclipse sometimes fails to find the JDK as it does not look at the JAVA_HOME environment variable. Most likely you ran into the following error:
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: /path/to/eclipse/jre
Sadly, eclipse does not look for the JAVA_HOME environment variable. Instead it tries to find a JRE in the eclipse/jre directory and will use it if available. As it is rather unusual to not have the Java Runtime installed globally it is a better option to tell eclipse where to find your installed JRE. You have two options to do that:
- Explicitly start eclipse with the -vm argument to start it with a JVM of your choice:
eclipse -vm /opt/java1.7/bin/java
While this is a viable solution, I prefer the solution shown in 2.
- It is possible to tell eclipse where the the runtime is installed through the eclipse.ini configuration file.
--launcher.defaultAction openFile -vm /opt/java1.7/bin/java -vmargs
This is similar to starting eclipse with the -vm argument, but by defining the option in the eclipse.ini it will automatically be loaded when you double-click the eclipse executable.
Important: The -vm option must be specified before -vmargs. Everything after -vmargs will be treated as an argument to the JVM.