Eclipse:找不到 Java 2 运行时环境

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4388448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 16:50:49  来源:igfitidea点击:

Eclipse: Could not find Java 2 Runtime Environment

javaeclipseruntime-environment

提问by Pascal Klein

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:

我刚刚安装了 Eclipse 3.5。在我安装 Android 插件之前,我需要安装一个 Java jdk,我做到了。重新启动后,我无法再启动 Eclipse,因为我收到以下错误:

Error: could not finde Java 2 Runtime Environment

错误:找不到 Java 2 运行时环境

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

奇怪的是,现在我什至无法打开用于 PHP 编程的其他 Eclipse 安装。有什么建议?

Update:

更新:

This is my eclipse.ini:

这是我的 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
-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

回答by Yusuf K.

Check your path variable from Computer's System Properties Environment Variables JAVA_HOME to ocorrect path to your jdk installation

从 Computer's System Properties Environment Variables JAVA_HOME 检查您的路径变量,以纠正您的 jdk 安装路径

回答by jzd

Make sure everything is setup correctly under "installed JREs" under the Eclipse preferences.

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

回答by dimitrisli

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

您可以通过在 eclipse.ini 中添加以下内容来明确告诉您的 eclipse 会话您希望它从哪个 jdk/jre 开始:

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

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

For more info on how to startup your eclipse refer here

有关如何启动 eclipse 的更多信息,请参阅此处

回答by Chris Dennett

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:

想知道 Java 安装是否可能已损坏。您能否在运行提示上运行以下命令并将您获得的内容粘贴到代码标签中:

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

回答by Joeri Hendrickx

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

您的 PHP eclipse 也不会启动是有道理的。Eclipse 在 java 本身上运行。可能它找不到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).
  • JRE 已损坏,您应该重新安装它
  • Eclipse 对 2 jre 感到困惑(对我来说不太可能),您需要将其指向正确的(如 Dimistrisli 所建议的)。

回答by makbeta

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.

我有一个类似的问题,除了 Java 安装成功。一旦我将 c:/my-path-to-java/jre/bin 添加到 PATH(系统环境变量),Eclipse 就成功启动了。

回答by Ophir

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)

我遇到过同样的问题。Eclipse (3.7) 在 JDK 6 上运行了一段时间,然后我安装了 JRE 5(请不要问我为什么)

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

这个 eclipse wiki page似乎是最新的,它指出:

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

如果eclipse/jre目录下安装了JVM,Eclipse会使用它;否则启动器将查询 eclipse.ini 文件和系统路径变量。Eclipse 不咨询 JAVA_HOME 环境变量

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:

事实上,我没有改变 JAVA_HOME 所以不可能是这样。然而,在同一个维基页面的底部,有人补充说:

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

关于 JVM 搜索顺序的评论(在 Windows 上) - 我的测试(Windows 7,Eclipse 3.4.1)显示 Eclipse 也在注册表中查找 JVM,在我的例子中是 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.

所以我找到了提到的注册表项,它现在的值为“1.5”并将其更改为“1.6”,然后重新启动我的 PC(Windows 7),瞧 - Eclipse 恢复了活力。

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.

我同意添加“-vm”可能会解决这个问题,尽管它似乎对我不起作用(也许我没有将它添加到正确的位置/格式)。但是 IMO,在我的情况下,注册表修复是更好的。重新启动计算机并看到 Eclipse 恢复正常后,我卸载了 JRE 5(通过“添加或删除程序”)只是为了解决问题。

回答by Moss

In my case installing the most recent JRE worked well: http://www.oracle.com/technetwork/java/javase/overview/index.html

在我的情况下,安装最新的 JRE 效果很好:http: //www.oracle.com/technetwork/java/javase/overview/index.html

回答by endless

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.

我最近安装 JDK 7 Update 9 时遇到了同样的问题。我的 eclipse 没有打开,当我从 CMD 运行“java -version”时,它也不起作用。我将 PATH 变量设置为正确的 bin 目录。

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.

无论如何,最终当我将 JAVA_HOME 设置为新的安装目录时,eclipse 启动正常。不确定 JDK 7 Update 9 有什么问题。

回答by palacsint

Change the PATHenvironment variable from something like

PATH从类似的东西更改环境变量

...;%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;...