5

I have a small problem with Eclipse on my Ubuntu machine. I installed JDK, set JAVA_HOME and PATH variables, all seems correct, but eclipse refuses to launch and throws an 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: /opt/eclipse/jre/bin/java java in your current PATH

have no clue what's the problem. help please.

note:

I am able to run java and javac in terminal.

Headshota
  • 21,021
  • 11
  • 61
  • 82

8 Answers8

13

If you get this error even though you already have JDK in your system-just follow this steps:

1)open eclipse.ini file with text editor.
2)copy your jdk path by using -vm command (vm and your path should not be in same line)
eg:
-vm        
/usr/lib/java/jdk1.7.0_75/jre/bin/java 
3)-vm should be placed before -vmargs in eclipse.ini file.

99% works if you follow above simple steps

Nagendra Reddy
  • 531
  • 5
  • 7
11

This worked for me:

ubuntu:~$ sudo apt-get install default-jre
Andro Selva
  • 53,910
  • 52
  • 193
  • 240
Craig Hawkins
  • 111
  • 1
  • 3
4

You need to create a link at /usr/bin/java for the java binary (wherever you have placed it).

sudo ln -s /path/to/jre*/bin/java /usr/bin/java
BZ1
  • 1,306
  • 2
  • 8
  • 10
2

You probably need to set your JAVA_HOME env var something like:

export JAVA_HOME=/apps/java/jdk1.6.0_13

Check this answer out

Community
  • 1
  • 1
Grammin
  • 11,808
  • 22
  • 80
  • 138
1
  1. open your eclipse.ini file
  2. add -vm usr/lib/jvm/jdk1.8.x_xx/jre/bin/java this must be placed before -vmarg

  3. save the file

  4. start your eclipse Happy Coding...
0

it seems eclipse looks for java under /usr/bin directory, making a symbolic link of the java command in this dir would solve your problems, at least solve mine

telmo
  • 153
  • 8
0

I have to run a number of jre and jdks on my machine and did not want to mess with the environment. I wanted to keep 1.6 for my environment but run eclipse under 1.7. I added the following line to my elcipse.ini file to specify the exact jvm to run eclipse:

-vm
/usr/lib/jvm/jdk1.7_latest/bin/java

Obviously your path might be different. Note that above jdk1.7_latest is a symlink to the specific version of the latest Java 7 jdk.

Hope that helps somebody.

OwainD
  • 838
  • 1
  • 9
  • 20
0

This is the problem of your jdk is not setup properly for current profile. Before starting eclipse in your current profile. Run "java -version" command on your current profile where you are running eclipse. Surely it will ask to install jdk/jre even jdk already installed but on different profile.

Hence there is two way: Solution 1. install jdk on current profile edit and add following lines vi /etc/profile export JAVA_HOME=/usr/local/jdk-1.8 export PATH=$PATH:$JAVA_HOME/bin

Solution 2: ~/.profiles export JAVA_HOME=/usr/local/jdk-1.8 export PATH=$PATH:$JAVA_HOME/bin

Solution 3: I tried and working perfectly for me. 1. gedit /home/../eclipse/eclipse.ini 2. Add following line before -vmargs and any plugin or jar execution in eclipse.ini file

-startup
-vm        
/usr/local/java/jdk1.8.0_251/bin/java.exe
plugins/org.eclipse.equinox.launcher_1.5.700.v20200207-2156.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1100.v20190907-0426
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx2048m
--add-modules=ALL-SYSTEM

This solution is perfectly working after explore from many stackoverflow suggestions and blogs.

Rajeev Rathor
  • 1,830
  • 25
  • 20