siva636
siva636

Reputation: 16451

Eclipse cannot find Java on Ubuntu

Java is properly installed in my Ubuntu 12.04 and the PATH variable is set in the .bashrc file.

The command java -version gives an expected output.

But when I try to start Eclipse, it complains as JDK not found.

enter image description here

Upvotes: 9

Views: 27321

Answers (8)

Manash Ranjan Dakua
Manash Ranjan Dakua

Reputation: 311

-vm /home/{Users_Directory}/Desktop/jdk-8u251-linux-x64/jdk1.8.0_251/bin

Upvotes: -1

Harsha
Harsha

Reputation: 1756

The Eclipse read me document has helped me solve this issue clearly.

If this seems to solve the problem, it is likely that the problem really was related to the use of GCJ as the Java runtime for running Eclipse. The eclipse.ini file located within Eclipse's folder can be altered to automatically pass this argument to Eclipse at startup. An example of its content is presented below:

  -showsplash
  org.eclipse.platform
  -vm
  /opt/jdk-1.8/bin/java
  -vmargs
  -Xms256m
  -Xmx1024m

So I had to put this the line before the -vmargs

Upvotes: 0

pintu
pintu

Reputation: 331

Follow below step to define path variable available for all launcher for manually installed JDK

Step:

1-

 cd /etc/

2-

sudo vim ~/.profile

3- Add below codes in your step2 open file

  PATH="$HOME/bin:$HOME/.local/bin:/usr/lib:$PATH"

  JAVA_HOME="/usr/lib/jvm/jdk1.7.0_79"

  export JAVA_HOME

  PATH=$PATH:$JAVA_HOME/bin

  export PATH

4-Restart your system

Upvotes: 0

Jeshurun
Jeshurun

Reputation: 23186

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.

Upvotes: 5

Kazekage Gaara
Kazekage Gaara

Reputation: 15052

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.

Upvotes: 11

Stephen C
Stephen C

Reputation: 719661

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.)

Upvotes: 6

Dunes
Dunes

Reputation: 40883

Install eclipse via the package manager and you shouldn't have this problem.

You've installed eclipse manually in your home directory and eclipse is trying to find a jre where it was installed, but you probably didn't download a version of eclipse that comes with its own jdk. As such it needs a little more help to work.

Like I said above, delete your current installation and install via the package manager.

Upvotes: 0

emilan
emilan

Reputation: 13075

You can explicitely tell your eclipse session which jdk/jre you want it to start with adding the following in your eclipse.ini:

-vm home/..../jre/bin/javaw.exe

Upvotes: 1

Related Questions