Java 找出运行 JVM Eclipse 的设备
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/557169/
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
Find out what JVM Eclipse is running on
提问by Christophe Herreman
I'm currently trying to tune my Eclipse installation and bumped into the "-vm" option. Other posts on SO mentioned that it's good to always use the latest JVM available because they keep getting better in terms of performance, so I'm likely to do that. I was wondering though how you could find out what JVM Eclipse runs on if you are not specifying the "-vm" parameter.
我目前正在尝试调整我的 Eclipse 安装并遇到了“-vm”选项。SO 上的其他帖子提到始终使用可用的最新 JVM 很好,因为它们在性能方面不断提高,所以我可能会这样做。我想知道如果您没有指定“-vm”参数,您如何才能找出运行 JVM Eclipse 的内容。
I found the following in the docs but that doesn't clarify how it will look for a JVM:
我在文档中发现了以下内容,但这并没有说明它将如何查找 JVM:
when passed to the Eclipse executable, this option is used to locate the Java VM to use to run Eclipse. It must be the full file system path to an appropriate Java executable. If not specified, the Eclipse executable uses a search algorithm to locate a suitable VM. In any event, the executable then passes the path to the actual VM used to Java Main using the -vm argument. Java Main then stores this value in eclipse.vm.
当传递给 Eclipse 可执行文件时,此选项用于定位用于运行 Eclipse 的 Java VM。它必须是相应 Java 可执行文件的完整文件系统路径。如果未指定,Eclipse 可执行文件将使用搜索算法来定位合适的 VM。在任何情况下,可执行文件都会使用 -vm 参数将路径传递到用于 Java Main 的实际 VM。Java Main 然后将此值存储在 eclipse.vm 中。
采纳答案by Don Branson
Actually, Windows->Preferences->Java->installed doesn't show you the one Eclipse runs under, but only the default JRE that it runs things under.
实际上,Windows->Preferences->Java->installed 并没有显示 Eclipse 在其下运行的一个,而只显示了它在其下运行的默认 JRE。
To see the one Eclipse is runing under, go to Help->About Eclipse Platform->Configuration Details, and look for the property eclipse.vm.
要查看正在运行的 Eclipse,请转到 Help->About Eclipse Platform->Configuration Details,然后查找属性 eclipse.vm。
For example:
例如:
eclipse.vm=C:\Program Files\Java\jre6\bin\client\jvm.dll
回答by dw.mackie
I think if you do:
Window->Preferences->Java->Installed JREs
you'll see a list of JREs on your machine.
The one that's checked is the one that eclipse is using.
我想如果你这样做:
Window->Preferences->Java->Installed JREs
你会在你的机器上看到一个 JRE 列表。检查的那个是eclipse正在使用的那个。
Alternatively, if you go into the "run configurations" dialog, and look at the JRE tab, you can pick a JRE to run on there.
或者,如果您进入“运行配置”对话框并查看 JRE 选项卡,您可以选择一个 JRE 来运行。
回答by Akrikos
If you go to Help->'About Eclipse Platform' and click on the 'Configuration Details' button it will take a moment to display, but you get a dump of everything eclipse is configured for...
如果您转到“帮助”->“关于 Eclipse 平台”并单击“配置详细信息”按钮,它将需要一些时间来显示,但是您会获得 Eclipse 为...配置的所有内容的转储...
I found these 2 lines to be what you're looking for:
我发现这 2 行正是您要查找的内容:
-vm
C:\Program Files\Java\jdk1.6.0_10\bin..\jre\bin\client\jvm.dll
-vm
C:\Program Files\Java\jdk1.6.0_10\bin..\jre\bin\client\jvm.dll
回答by VonC
According to this threadand this one:
eclipse will try to locate your JVM used for launchingitself by examining your path.
eclipse 将尝试通过检查您的路径来定位用于启动自己的JVM 。
So, you can:
这样你就可以:
Create a JAVA_HOME environment variable, that points to your actually preferred JDK.
This way you can easily choose between JDKs installed.Put %JAVA_HOME%\bin in the path, anywhere preceeding
<windowsroot>\system32
, which also contains java, javaw & co binaries.
This way the java* in the JDK bin directory is invoked whenever it is invoked from the path.
创建一个 JAVA_HOME 环境变量,指向您实际首选的 JDK。
通过这种方式,您可以轻松地在安装的 JDK 之间进行选择。将 %JAVA_HOME%\bin 放在路径中的任何位置
<windowsroot>\system32
,其中还包含 java、javaw 和 co 二进制文件。
这样,每当从路径调用时,就会调用 JDK bin 目录中的 java*。
I believe the other posts tell you how to find what JVM eclipse is using.
我相信其他帖子会告诉您如何找到 JVM eclipse 正在使用的内容。
However, I interpreted your question as: "what JVM will eclipse will usewhen launching itself ?" when no -vm
args is used.
但是,我将您的问题解释为:“eclipse启动时将使用什么 JVM ?” 当没有使用-vm
args时。
After further research, it appears that eclipse will look for a JRE:
经过进一步研究,eclipse 似乎会寻找 JRE:
- either directly under its installation directory (
<eclipse>\jre
): if you copy the content of any installed JRE in that sub-directory, it will be selected - in
C:\Program Files\Java\JRE...
. - in the
%PATH%
(see above)
- 要么直接在其安装目录 (
<eclipse>\jre
) 下:如果您将任何已安装 JRE 的内容复制到该子目录中,它将被选中 - 在
C:\Program Files\Java\JRE...
。 - 在
%PATH%
(见上文)
Also read this SO answerto see why eclipse will by default select jvm.dll instead of javaw.exe
另请阅读此SO 答案以了解为什么 eclipse 将默认选择 jvm.dll 而不是 javaw.exe