Eclipse - 没有 Java (JRE) / (JDK) ...没有虚拟机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2030434/
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-13 02:48:15  来源:igfitidea点击:

Eclipse - no Java (JRE) / (JDK) ... no virtual machine

eclipsepathjava

提问by Wallter

I am trying to get Eclipse v3.5 (Galileo) to re-run on my computer - I have run it before with no problems, but nowI keep getting this error:

我正在尝试让 Eclipse v3.5 (Galileo) 在我的计算机上重新运行 - 我之前运行过它没有任何问题,但现在我不断收到此错误:

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: C:\eclipse\jre\javaw.exe javaw.exe in your current PATH

为了运行 Eclipse,Java 运行时环境 (JRE) 或 Java 开发工具包 (JDK) 必须可用。搜索以下位置后未找到 Java 虚拟机:C:\eclipse\jre\javaw.exe javaw.exe in your current PATH

I've just done a fresh install of both the JDK and the SDK.

我刚刚完成了 JDK 和 SDK 的全新安装。

I have Windows 7 (x64).

我有 Windows 7 (x64)。

What's up with this? How do I fix it?

这是怎么回事?我如何解决它?

I can't run any of the ipconfig / tracert / or ping.

我无法运行任何 ipconfig / tracert / 或 ping。

采纳答案by VonC

Eclipse will by default try to launch with the default "java.exe" (the first one referenced by your PATH)

默认情况下,Eclipse 将尝试使用默认的“ java.exe”(您的 引用的第一个PATH)启动

Three things to remember:

要记住的三件事:

  • "Installing" a JRE or a JDKcan be as simple as unzipping or copying it from another computer: there is no special installation steps, and you can have as many different JVM versions (1.4, 5.0, 6.0...) as you want, "installed" (copied) almost anywhere on your disk.
  • I would recommend to always run Eclipse with the lastest JREpossible (to benefit from the latest hotspotevolutions). You can:
  • The JVM you will reference withinyour Eclipse session is notalways the one used for launching Eclipse because:
    • You only need a JRE to launch Eclipse, but once Eclipse launched, you should register a JDK for your projects (especially for Java sources and debugging purposes, also in theory for compilation but Eclipse has its own Java compiler) Note: You could register just a JRE within Eclipse because it is enough to runyour program, but again a JDK will allow for more operations.
    • Even though the default registered Java in Eclipse is the one used to launch the session, you can want to register an older SDK (including a non-Sun one) in order to run/debug your programs with a JRE similar to the one which will actually be used in production.
  • “安装” JRE 或 JDK可以像从另一台计算机解压缩或复制一样简单:没有特殊的安装步骤,您可以拥有任意多个不同的 JVM 版本(1.4、5.0、6.0...) ,“安装”(复制)在您磁盘上的几乎任何位置。
  • 我建议始终使用最新的 JRE运行 Eclipse (以从最新的热点演变中受益)。你可以:
  • 您将Eclipse 会话中引用的 JVM并不总是用于启动 Eclipse 的,因为:
    • 您只需要一个 JRE 来启动 Eclipse,但是一旦 Eclipse 启动,您应该为您的项目注册一个 JDK(特别是用于 Java 源代码和调试目的,理论上也用于编译,但 Eclipse 有自己的 Java 编译器) 注意:您可以只注册Eclipse 中的 JRE,因为它足以运行您的程序,但 JDK 将允许更多操作。
    • 尽管 Eclipse 中默认注册的 Java 是用于启动会话的 Java,但您可能希望注册一个较旧的 SDK(包括非 Sun 的 SDK),以便使用类似于 JRE 的 JRE 来运行/调试您的程序实际用于生产。

Installed JREs

已安装的 JRE



June 2012, jmbertuccicomments:

2012 年 6 月,jmbertucci评论:

I'm running Windows 7 64-bit and I had the 32-bit JRE installed. I downloaded Eclipse 64-bit which looks for a 64-bit JRE. Because I didn't have the 64-bit JRE it threw the error, which makes sense.

I went to the Java manual install page (which was not as directly accessible as you'd like) and installed the 64-bit version. See "Java Downloads for All Operating Systems". That was all I needed.

我运行的是 64 位 Windows 7,并且安装了 32 位 JRE。我下载了寻找 64 位 JRE 的 Eclipse 64 位。因为我没有 64 位 JRE,所以它抛出了错误,这是有道理的。

我转到 Java 手册安装页面(它不像您希望的那样直接访问)并安装了 64 位版本。请参阅“适用于所有操作系统的 Java 下载”。这就是我所需要的。



April 2016: Steve Mayneadds in the comments:

2016 年 4 月:Steve Mayne在评论中补充

I had to edit the eclipse.inifile to reference the correct Java path - Eclipse doesn't use the environment PATHat all when there is a value in eclipse.ini.

我必须编辑eclipse.ini文件以引用正确的 Java 路径 -PATHeclipse.ini.

回答by Topher Fangio

Try setting your JAVA_HOME to the correct folder. Google for setting environment variables in Windows.

尝试将您的 JAVA_HOME 设置为正确的文件夹。谷歌用于在 Windows 中设置环境变量。

回答by Drew Wills

Check Window > Preferences > Java > Installed JREs. Make sure there's something there; if there isn't, add one.

检查窗口 > 首选项 > Java > 已安装的 JRE。确保那里有东西;如果没有,加一个。

Did you recently update your JDK?

您最近是否更新了 JDK?

回答by Thorbj?rn Ravn Andersen

The JDK does not install a JVM in the default path.

JDK 不会在默认路径中安装 JVM。

Unless you need external tools to run like ant, the non-JDK is enough for Eclipse to run. The easiest way to install such a JVM is to go to http://java.comand let it install whatever it want to install.

除非你需要外部工具像 ant 一样运行,否则非 JDK 足以让 Eclipse 运行。安装此类 JVM 的最简单方法是访问http://java.com并让它安装它想要安装的任何内容。

Then double-click the Eclipse binary again.

然后再次双击 Eclipse 二进制文件。

回答by Rob Oxspring

Open up Windows' System Properties from the control panel and hunt down the environment variables section:

从控制面板打开 Windows 的系统属性并查找环境变量部分:

  • Add a JAVA_HOME entry pointing to the directory where the JDK is installed (e.g. C:\Program Files\Java\jre6)
  • Find the Path entry and add the following onto the end ;%JAVA_HOME%\bin
  • OK the changes
  • Restart eclipse so that it is aware of the new environment
  • 添加指向 JDK 安装目录的 JAVA_HOME 条目(例如 C:\Program Files\Java\jre6)
  • 找到 Path 条目并将以下内容添加到末尾 ;%JAVA_HOME%\bin
  • 确定更改
  • 重新启动 eclipse 以便它知道新环境

Most Java tools will now be able to find your Java installation either by using the JAVA_HOME environment variable or by looking for java.exe / javaw.exe in the Path environment variable.

大多数 Java 工具现在可以通过使用 JAVA_HOME 环境变量或通过在 Path 环境变量中查找 java.exe / javaw.exe 来找到您的 Java 安装。

回答by scienty

set JAVA_HOME variable and ad JAVA_HOME/bin to evnrionment path variable.

将 JAVA_HOME 变量和广告 JAVA_HOME/bin 设置为 evnrionment 路径变量。

回答by BalusC

All the other answers about setting onlythe JAVA_HOMEare not entirely right. Eclipse does namely notconsult the JAVA_HOME. Look closer at the error message:

所有关于设置其他的答案只有JAVA_HOME不完全正确。Eclipse 即参考JAVA_HOME. 仔细查看错误消息:

...in your current PATH

...在您当前的路径中

It literally said PATH, not JAVA_HOME.

它从字面上说PATH,不是JAVA_HOME

Rightclick My Computerand choose Properties(or press Winkey+Pause), go to the tab Advanced, click the button Environment Variables, in the System Variableslist at the bottom select Path(no, notClasspath), click Editand add ;c:\path\to\jdk\binto the end of the value.

右击我的电脑,选择属性(或按Winkey+ Pause),转到标签高级,点击按钮环境变量,在系统变量列表底部的选择Path(没有,没有Classpath),点击编辑,并添加;c:\path\to\jdk\bin到值的末尾。

Alternatively and if not present, you can also add JAVA_HOMEenvironment variable and make use of it in the PATH. In the same dialogue click Newand add JAVA_HOMEwith the value of c:\path\to\jdk. Then you can add ;%JAVA_HOME%\binto end of the value of the Pathsetting.

或者,如果不存在,您还可以添加JAVA_HOME环境变量并在PATH. 在同一个对话框中单击New并添加JAVA_HOME值为c:\path\to\jdk。然后您可以添加;%JAVA_HOME%\binPath设置值的末尾。

回答by laura

I had a co-worker with this exact problem last week. He fixed it by installing the x64 version of Eclipse and the x64 JDK.

上周我有一个同事解决了这个问题。他通过安装 x64 版本的 Eclipse 和 x64 JDK 来修复它。

Edit: he reused his old workspace after installing the necessary plugins, so that should not be much of an issue

编辑:他在安装必要的插件后重用了他的旧工作区,所以这应该不是什么大问题

回答by Wallter

It turned out that all I needed to do was change the 'path'to:

事实证明,我需要做的就是将“路径”更改为:

"C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem; C:\Program Files (x86)\Java; C:\Program Files (x86)\Java\jdk1.6.0_14\bin"

"C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\Java;C:\Program Files (x86)\Java\jdk1.6.0_14\bin ”

that did it :)

做到了:)

回答by Tim

I had the same issue (Windows 7 x64, 64bit JDK, 32bit Eclipse), and I found 2 solutions:

我遇到了同样的问题(Windows 7 x64、64 位 JDK、32 位 Eclipse),我找到了 2 个解决方案:

  • Install the 64 bit version of Eclipse (found by clicking the "Development Builds" tab on the downloads page.)
  • Install the 32bit version of the JDK.
  • 安装 64 位版本的 Eclipse(通过单击下载页面上的“Development Builds”选项卡找到。)
  • 安装 32 位版本的 JDK。