Java Eclipse 如何找到 JRE 或 JDK 位置?

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

How Does Eclipse find the JRE or JDK locaton?

javawindowseclipsejvm

提问by MaheshVarma

According to the Eclipse FAQ. I read that

根据 Eclipse 常见问题解答。我读到了

Eclipse DOES NOT consult the JAVA_HOME environment variable.

Eclipse DOES NOT consult the JAVA_HOME environment variable.

My doubt is how does eclipse initializes the Virtual Machine. It does not know the location of Java. My eclipse.inifile does not have -vmconfiguration. Still I am able to run eclipse.

我的疑问是 eclipse 如何初始化Virtual Machine. 它不知道 的位置Java。我的eclipse.ini文件没有-vm配置。我仍然能够运行日食。

The Source

来源

UPDATE

更新

According to Eclipse Installation Guide. Eclipse does not write entries to the Windows registry.

根据 Eclipse安装指南Eclipse does not write entries to the Windows registry.

采纳答案by Tomas Narros

As far as I know, to invoke the JVM, Eclipse executes the javacommand, so, if it's at your system execution path, Eclipse won't need to find the instalation directory.

据我所知,为了调用 JVM,Eclipse 会执行java命令,因此,如果它在您的系统执行路径中,Eclipse 将不需要找到安装目录。

To check, you can start a OS shell and execute the next command (from any location):

要进行检查,您可以启动 OS shell 并执行下一个命令(从任何位置):

> java -version

EDIT:I was (partially) wrong. From the FAQ (http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM)

编辑:我(部分)错了。来自常见问题解答(http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM

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/jre目录下安装了JVM,Eclipse会使用它;否则启动器将查询 eclipse.ini 文件和系统路径变量

So, Eclipse first looks inside its eclipse/jre dir for installed VMs, if empty, consults the eclipse.ini file, and at last, looks at the system path.

因此,Eclipse 首先在其 eclipse/jre 目录中查找已安装的 VM,如果为空,则查阅 eclipse.ini 文件,最后查看系统路径。

回答by Keith Madsen

Eclipse will run using whatever version of JRE you have installed. To see/edit the version being used, go to Preferences -> Java -> Installed JREs

Eclipse 将使用您安装的任何版本的 JRE 运行。要查看/编辑正在使用的版本,请转到首选项 -> Java -> 已安装的 JRE

回答by Sagar

Even Help->Installation details->Configuration would give you the exact version and type of jvm you are using . Here it is clearly given in System Properties

甚至 Help->Installation details->Configuration 也会为您提供您正在使用的 jvm 的确切版本和类型。这里在系统属性中明确给出

回答by Jitesh

Or just run a java program in Eclipse. Eclipse will show the full path of javaw command it is using.

或者只是在 Eclipse 中运行一个 java 程序。Eclipse 将显示它正在使用的 javaw 命令的完整路径。

回答by Ankit Pandoh

Eclipse looks for system Path variable to get the installed JVM. It depends upon how you have defined path variable. Order in which several versions have been defined in path does matter i.e. if jdk1.5/bin is set before jdk1.6/bin, system will pick 1.5 version when you execute java -version on cmd

Eclipse 查找系统路径变量以获取已安装的 JVM。这取决于您如何定义路径变量。在路径中定义多个版本的顺序很重要,即如果 jdk1.5/bin 设置在 jdk1.6/bin 之前,当您在 cmd 上执行 java -version 时,系统将选择 1.5 版本

回答by Agusarif

Solved!

解决了!

1) downloaded and installed 64-bit versions of both the ADT for Android (Eclipse) and JDK Java bundle

1) 下载并安装了 64 位版本的 ADT for Android (Eclipse) 和 JDK Java 包

2)updated the PATH environmental variables (Win Control panel...System...advanced opt...Envir.variables) In my case it now looks like this: C:\Program\Java\jre7\bin\client\jvm.dll;C:\Program\Java\jdk1.7.0_21\bin

2)更新了 PATH 环境变量(Win Control panel...System...advanced opt...Envir.variables)在我的情况下它现在看起来像这样:C:\Program\Java\jre7\bin\client\jvm .dll;C:\Program\Java\jdk1.7.0_21\bin

(no backslash after the \bin directory)

(\bin 目录后没有反斜杠)

回答by theRiley

These days on WIN64, oracle creates a couple of new directories and adds them to your path. The one eclipse will default to is the second directory you specify in the installation process, because that gets loaded at the head of the path ahead of your JAVA_HOME. It is confusing why they ask you for two directories, I have no answer for that. I blew away the second directory, removed the two added directories from the path, configure my JAVA_HOME environment variable (in my case already on the path pointing to an older version) accordingly, and eclipse is good to go.

这些天在 WIN64 上,oracle 创建了几个新目录并将它们添加到您的路径中。一个 eclipse 将默认为您在安装过程中指定的第二个目录,因为它被加载到 JAVA_HOME 之前的路径的头部。他们问你两个目录的原因令人困惑,我对此没有答案。我吹掉了第二个目录,从路径中删除了两个添加的目录,相应地配置了我的 JAVA_HOME 环境变量(在我的情况下已经在指向旧版本的路径上),并且 eclipse 很好。