Eclipse JVM configuration

2019-01-14 07:26发布

Background: I've got a new eclipse installation and have installed the m2eclipse plugin. After startup m2eclipse generates the message:

Eclipse is running in a JRE, but a JDK is required

Following the instructions from here I've changed the eclipse.ini file to use the 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.

Looking at the eclipse configuration via Help -> About Eclipse -> Installation Details -> Configuration it seems like eclipse is picking up the JVM configuration details from somewhere else:

...
-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
eclipse.p2.data.area=@config.dir/../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 -vm argument coming from and how can I remove or change it?

Thanks

Update: I have updated the eclipse.ini file as per VonC's answer. I'm now getting an error when launching eclipse saying:

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"

I've confirmed that the path is correct and can be executed via the command line.

Complete eclipse.ini below:

-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:

-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

8条回答
Explosion°爆炸
2楼-- · 2019-01-14 07:46

My issue was that -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

查看更多
Melony?
3楼-- · 2019-01-14 07:52

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

"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.

Howto start eclipse in JDK?

查看更多
劳资没心,怎么记你
4楼-- · 2019-01-14 08:03

See:

for an example of parameters order.

-vm should be before -vmargs


Update 6 years laters (2015)

E Riz mentions in the comments that the new Eclipse Installer will detect the JVM for you, or propose ones to download.

https://www.eclipse.org/downloads/assets/public/images/installer-instructions-04.png

查看更多
放荡不羁爱自由
5楼-- · 2019-01-14 08:04

This also addressed in Eclipse documentation: https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Windows_Example

查看更多
一夜七次
6楼-- · 2019-01-14 08:07

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
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
查看更多
Anthone
7楼-- · 2019-01-14 08:08

Unbelievable, the solution to this problem for me has nothing to do with slashes, backslashes, quotes, spaces, jre, jdk, jvm, javaw, ....

The answer is that you have to have a line break between -vm and the path.

So in the eclipse.ini file:

THIS WILL NOT WORK:

-vm C:\java\jdk\bin\javaw.exe

BUT THIS WILL:

-vm
C:\java\jdk\bin\javaw.exe
查看更多
登录 后发表回答