Eclipse cannot find Java on Ubuntu

Java in Ubuntu is usually located at /usr/lib/jvm/<your_java_version>, but ubuntu usually creates a symlink to the current version of java at /usr/lib/jvm/java-7-sun. The symlink may or may not exist depending on how you installed java on your machine, now that it is no longer available at the repos.

Navigate to /usr/lib/jvm/ and type the ls command to find the appropriate folder java is located in. Once you have the location nailed down, look for a file named libjvm.so.

In my machine, the -vm arg looks like this:

-vm
/usr/lib/jvm/java-6-sun/jre/lib/amd64/server/libjvm.so

Make sure the path is in a new line below -vm or it won't work.


It looks to me like you have set the PATH environment in your shell, but you are launching Eclipse using some menu item or shortcut, and the context is using a different PATH.

One option is to change the eclipse.ini file as other answers say.

Another option is to try to figure out why Eclipse is being launched with a different PATH to the one in your command path. (The "fix" might simply be to logout and login again to make the launcher pick up the updated PATH setting. Or launcher may be picking up the incorrect PATH setting from somewhere else.)


You might need to edit your eclipse.ini file and mention the path there. Read this for more details.

EDIT:

 -vm
/opt/sun-jdk-1.6.0.02/bin/java

This is how your vm argument should be in the .ini file. If not,change it. Be careful about the path though. Generally Java is installed in /opt,but check once on your system.

Also, look at this question as well.