Eclipse JVM 配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1410511/
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
Eclipse JVM configuration
提问by Jared Russell
Background: I've got a new eclipse installation and have installed the m2eclipse plugin. After startup m2eclipse generates the message:
背景:我有一个新的 eclipse 安装并且已经安装了 m2eclipse 插件。启动后 m2eclipse 生成消息:
Eclipse is running in a JRE, but a JDK is required
Eclipse 在 JRE 中运行,但需要 JDK
Following the instructions from hereI've changed the eclipse.ini file to use the JDK JVM:
按照此处的说明,我将 eclipse.ini 文件更改为使用 JDK JVM:
-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-vm
"C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe"
After restarting eclipse however, I still get the message saying its running under the JRE and not the JDK.
但是,在重新启动 eclipse 后,我仍然收到消息说它在 JRE 而不是 JDK 下运行。
Looking at the eclipse configuration via Help -> About Eclipse -> Installation Details -> Configurationit seems like eclipse is picking up the JVM configuration details from somewhere else:
通过Help -> About Eclipse -> Installation Details -> Configuration 查看eclipse配置,似乎 eclipse 正在从其他地方获取 JVM 配置详细信息:
...
-vm
C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll
eclipse.home.location=file:/C:/Program Files (x86)/eclipse/
eclipse.launcher=C:\Program Files (x86)\eclipse\eclipse.exe
[email protected]/../p2/
eclipse.p2.profile=epp.package.jee
eclipse.product=org.eclipse.epp.package.jee.product
eclipse.startTime=1252669330296
eclipse.vm=C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-vm
"C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe"
-XX:MaxPermSize=256m
...
My question is where is the first -vmargument coming from and how can I remove or change it?
我的问题是第一个-vm参数来自哪里,如何删除或更改它?
Thanks
谢谢
Update: I have updated the eclipse.ini file as per VonC's answer. I'm now getting an error when launching eclipse saying:
更新:我已经根据 VonC 的回答更新了 eclipse.ini 文件。我现在在启动 eclipse 时收到一个错误说:
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:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe"
Java 运行时环境 (JRE) 或 Java 开发工具包 (JDK) 必须可用才能运行 Eclipse。搜索以下位置后没有找到Java虚拟机:“C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe”
I've confirmed that the path is correct and can be executed via the command line.
我已经确认路径是正确的,可以通过命令行执行。
Complete eclipse.ini below:
完成下面的eclipse.ini:
-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.jee.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vm
"C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe"
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
Solution:it seems like there was still something wrong with the eclipse.ini file. I replaced it completely with the settings given by VonC in the post he linked and eclipse is now starting properly and using the correct JVM. Full eclipse.ini below for anyone else with the same problem:
解决方案:eclipse.ini 文件好像还是有问题。我用 VonC 在他链接的帖子中给出的设置完全替换了它,eclipse 现在可以正常启动并使用正确的 JVM。下面的完整 eclipse.ini 用于其他有相同问题的人:
-showlocation
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
384m
-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-vm
C:\Program Files (x86)\Java\jdk1.6.0_16\jre\bin\client\jvm.dll
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms128m
-Xmx384m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-Dcom.sun.management.jmxremote
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=C:/jv/eclipse/mydropins
采纳答案by VonC
See:
看:
for an example of parameters order.
以参数顺序为例。
-vm
should be before -vmargs
-vm
应该在之前 -vmargs
Update 6 years laters (2015)
6 年后更新(2015 年)
E Rizmentions in the commentsthat the new Eclipse Installerwill detect the JVM for you, or propose ones to download.
E Riz在评论中提到,新的 Eclipse 安装程序将为您检测 JVM,或者建议您下载。
回答by Jeremy Goodell
Unbelievable, the solution to this problem for me has nothing to do with slashes, backslashes, quotes, spaces, jre, jdk, jvm, javaw, ....
难以置信,对我来说这个问题的解决方案与斜杠、反斜杠、引号、空格、jre、jdk、jvm、javaw、...无关。
The answer is that you have to have a line break between -vm
and the path.
答案是您必须在-vm
和 路径之间换行。
So in the eclipse.ini file:
所以在 eclipse.ini 文件中:
THIS WILL NOT WORK:
这行不通:
-vm C:\java\jdk\bin\javaw.exe
BUT THIS WILL:
但这将:
-vm
C:\java\jdk\bin\javaw.exe
回答by vpram86
I think your machine is 64bit windows?
我想你的机器是64位windows?
I cannot see a 64bit windows version of eclipse in the site. So only 32 bit might be available. Are you sure you have a 32bit JDK installed in your machine? Just a thought...
我在网站上看不到 64 位 Windows 版本的 eclipse。所以可能只有 32 位可用。您确定您的机器上安装了 32 位 JDK?只是一个想法...
回答by Jo?o Quintas
This also addressed in Eclipse documentation: https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example
这也在 Eclipse 文档中解决:https: //wiki.eclipse.org/Eclipse.ini#-vm_value: _Windows_Example
回答by Jolly1234
My issue was that -vm "C:\Program Files\Java\jdk1.7.0_67\jre\bin\javaw.exe"
我的问题是 -vm "C:\Program Files\Java\jdk1.7.0_67\jre\bin\javaw.exe"
the path was in quotes, when i removed the quotes it worked:
路径在引号中,当我删除引号时它起作用了:
-vm C:\Program Files\Java\jdk1.7.0_67\jre\bin\javaw.exe
-vm C:\Program Files\Java\jdk1.7.0_67\jre\bin\javaw.exe
回答by Abdollah
You should mention the full path of javaw.exe after -vm argument without using double quotes, i.e. "", each of -vm and the path has to be in different lines and -vm must be before -vmargs. For example:
你应该在 -vm 参数之后提到 javaw.exe 的完整路径,而不使用双引号,即“”,每个 -vm 和路径必须在不同的行中,并且 -vm 必须在 -vmargs 之前。例如:
-vm
C:\Program Files\Java\jrockit-jre1.6.0_45-R28.2.7\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m
-XX:+UnlockDiagnosticVMOptions
-XX:MaxClassBlockMemory=75M
回答by Abhijeet
If you're using Windows, right click on your eclipse shortcut and select Properties, in the Shortcut tab you can change what's in the Target: box to specify the jdk. I use
如果您使用的是 Windows,请右键单击您的 eclipse 快捷方式并选择“属性”,在“快捷方式”选项卡中,您可以更改“目标:”框中的内容以指定 jdk。我用
"C:\Program Files\eclipse-jee-galileo-sr1 (3.5.1)\eclipse.exe" -vm "C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe" -vmargs -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode For some reason I couldn't get it to use the jdk when I tried editing the eclipse.ini file.
"C:\Program Files\eclipse-jee-galileo-sr1 (3.5.1)\eclipse.exe" -vm "C:\Program Files\Java\jdk1.6.0_16\bin\javaw.exe" -vmargs -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode 由于某种原因,当我尝试编辑 eclipse.ini 文件时,我无法让它使用 jdk。
回答by z8888q
I solve this question.
我解决这个问题。
When you create a Maven Project in Eclipse maybe the text file encoding in this project's properties and the project.build.sourceEncoding
in the pom.xml
was not the same. When you build this project it would report "Unable to locate the Javac Compiler in:..." error, too.
当您在 Eclipse 中创建 Maven 项目时,该项目的属性中的文本文件编码可能与project.build.sourceEncoding
中的pom.xml
不一样。当您构建此项目时,它也会报告“无法在以下位置找到 Javac 编译器:...”错误。
For example, my text file encoding was GBK and project.build.sourceEncoding
was UTF-8 so this error happened. I just modified the text file encoding to UTF-8.
例如,我的文本文件编码是 GBK 和project.build.sourceEncoding
UTF-8,所以发生了这个错误。我只是将文本文件编码修改为 UTF-8。