简体   繁体   中英

Eclipse: Could not find Java 2 Runtime Environment

I just installed Eclipse 3.5. Before I could install the Android Plugin I needed to install a Java jdk, which I did. After restart Im not able to start Eclipse anymore, because I receive the following error:

Error: could not finde Java 2 Runtime Environment

The weired thing is, that now I cant even open my other Eclipse Installations, that I use for PHP Programming. Any suggestions?

Update:

This is my eclipse.ini:

 -startup plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.0.200.v20090519 -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -vmargs -Xms40m -Xmx256m 

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

-vm
c:/your/jre/bin/javaw.exe

For more info on how to startup your eclipse refer here

I had a similar problem, with exception that Java was installed successfully. Once I added c:/my-path-to-java/jre/bin to PATH (system environment variable), Eclipse started successfully.

Change the PATH environment variable from something like

...;%SystemRoot%\System32;...;C:\Program Files\Java\jdk1.7.0_17\bin;...

to something like

...;C:\Program Files\Java\jdk1.7.0_17\bin;...;%SystemRoot%\System32;...

从计算机的系统属性环境变量JAVA_HOME检查路径变量到jdk安装的正确路径

I had the same problem when I recently installed JDK 7 Update 9. My eclipse did not open and when I run "java -version" from CMD, it did not work either. I had PATH variable set to the correct bin directory.

Anyways, eventually when I set JAVA_HOME to the new installation directory, eclipse started fine. Not sure what is the problem with JDK 7 Update 9.

Wonder if the Java install might be corrupt. Can you run the following on the Run prompt and paste what you get in code tags:

dir /d /s "%JAVA_HOME%" > "%HOMEPATH%\java2.txt" && notepad "%HOMEPATH%\java2.txt"

It makes sense that your PHP eclipse won't start either. Eclipse runs on java itself. Probably it cannot find the JRE.

so I see two possibilities:

  • The JRE is corrupt and you should reinstall it
  • Eclipse is getting confused by the 2 jre (unlikely to me) and you need to point it to the right one (as suggested by Dimistrisli).

I had the same issue. Eclipse (3.7) worked just fine for a while with JDK 6, and then I installed JRE 5 (please don't ask me why)

This eclipse wiki page , which seems up to date, states that:

If a JVM is installed in the eclipse/jre directory, Eclipse will use it; otherwise the launcher will consult the eclipse.ini file and the system path variable. Eclipse DOES NOT consult the JAVA_HOME environment variable

And indeed, I did not change JAVA_HOME so that couldn't be it. However, at the bottom of the same wiki page, someone added:

A comment on the JVM search order (on Windows) - My testing (Windows 7, Eclipse 3.4.1) shows that Eclipse also looks for a JVM in the registry, in my case HKLM\\Software\\Wow6432Node\\JavaSoft\\Java Runtime Environment

So I found the mentioned registry entry, which now had the value of "1.5" and changed it to "1.6", then restarted my PC (windows 7), and voila - Eclipse went back alive.

I agree that adding "-vm" might fix this, although it didn't seem to work for me (maybe I didn't add it in the right place/format). But IMO, the registry fix was the better one in my case. After restarting my computer and seeing Eclipse was back to normal, I uninstalled JRE 5 (through "Add or remove programs") just to tie up loose ends.

在我的情况下安装最新的JRE运行良好: http//www.oracle.com/technetwork/java/javase/overview/index.html

The simple solution that worked for me, since other resolution required admin privilege is executing the below command from command prompt

eclipse -vm C:\\Java\\jdk1.7.0_72\\bin\\javaw

Also, to make the eclipse shortcut work by editing the shortcut.Append -vm C:\\Java\\jdk1.7.0_72\\bin\\javaw in the target section

确保在Eclipse首选项下的“已安装的JRE”下正确设置了所有内容。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM