17

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
Jared Russell
  • 10,804
  • 6
  • 30
  • 31
  • Beware of any space at the end of your path. Complete your question with the new eclipse.ini for us to debug. – VonC Sep 11 '09 at 12:31
  • You don't need double quotes around the -vm argument, even if there are spaces in the path. I also use forward slashes / (yes, even on windows). – SteveD Sep 11 '09 at 12:49
  • Just tried that, after removing the quotes from the launcher just seems to quit and not do anything (not even getting the error message). – Jared Russell Sep 11 '09 at 12:52
  • 1
    As Aviator says, you need Eclipse and the JDK to match in terms of architecture - either both 32bit or both 64bit. – SteveD Sep 11 '09 at 13:08
  • You did use the settings for eclipse3.5, but not completely: you have twice the --launcher directive. Please copy *completely* my settings, and adapt them. – VonC Sep 11 '09 at 13:16
  • You're right, I completely replaced my settings with yours and it now seems to be working correctly. Thanks for the help :) – Jared Russell Sep 11 '09 at 13:22
  • You are welcome. I thought seeing twice the `--launcher.XXMaxPermSize ` directive was not very "clean" :) – VonC Sep 11 '09 at 13:30
  • Note: the last line: `-Dorg.eclipse.equinox.p2.reconciler.dropins.directory` should reference a path where you can unzip your plugins across different eclipse installations. If that path does not exist, it will still run, but you should know what it is for. – VonC Sep 11 '09 at 13:31

8 Answers8

12

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

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes, -vm must before -vmargs. See the end of http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.user/tasks/running_eclipse.htm – Csaba_H Sep 11 '09 at 12:21
  • I've tried this and am now getting an error saying that no JVM could be found at the specified location. The path is correct so this must be something to do with eclipse. Any ideas? – Jared Russell Sep 11 '09 at 12:28
  • I had the same problem , the solution written here solved the error when eclipse loaded, but when i try to build using maven plugin. it is showing me [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project trojantime: Compilation failure Unable to locate the Javac Compiler in: C:\Program Files\Java\jre6\..\lib\tools.jar – jmj Jul 23 '10 at 10:32
  • @org: that shouldn't be related to the `eclipse.ini` settings, but to the JRA installed. See http://stackoverflow.com/questions/1431531/how-is-the-eclipse-jdk-setting-affecting-the-systems-jdk-setting/1431554#1431554 (and just in case http://stackoverflow.com/questions/1773060/programmatically-configure-eclipse-installed-jres/1773827#1773827) – VonC Jul 23 '10 at 10:51
  • The simplest approach now is to use the Eclipse Installer. See http://stackoverflow.com/a/31885692/639520 – E-Riz Aug 12 '15 at 15:31
  • @E-Riz good point. I have included your comment in the answer for more visibility. – VonC Aug 12 '15 at 17:10
7

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
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
Jeremy Goodell
  • 18,225
  • 5
  • 35
  • 52
2

I think your machine is 64bit 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...

vpram86
  • 5,860
  • 4
  • 28
  • 40
  • You're correct, I've got the 64-bit version of the JDK installed and thats what I've got eclipse pointing to. I'll try downloading the 32-bit version and see if I have any better luck. – Jared Russell Sep 11 '09 at 12:48
  • No luck I'm afraid, pointing to the 32-bit JDK gives the same error. – Jared Russell Sep 11 '09 at 12:55
  • Did you try putting -vm to point 32bit jvm.dll instead of javaw.exe? (use jre inside the JDK for searching jvm.dll) – vpram86 Sep 11 '09 at 13:07
  • 64-bit Eclipse is well hidden on the website as it's not an official platform (god knows why, we've had 64-bit for a while). Here it is: http://download.eclipse.org/eclipse/downloads/drops/R-3.5-200906111540/index.php – SteveD Sep 11 '09 at 13:11
  • Yeah have tried that as well. It gives exactly the same error about not finding a JVM. I've also found that there is a 64-bit windows version of eclipse here: http://download.eclipse.org/eclipse/downloads/drops/R-3.5-200906111540/index.php This version also generates the same error about not finding a JVM when pointed to the 64- bit JVM. – Jared Russell Sep 11 '09 at 13:12
  • looks like steven beat me to the link :) – Jared Russell Sep 11 '09 at 13:13
  • @stevendick: @jared: Wow! I could have never found it. THanks guyz! @jared:Oh! :(. I thought it might solve the problem. my bad! – vpram86 Sep 11 '09 at 13:15
  • Hi jared.. sorry about so many options; :) Did you try the bin path of JDK? like this; -vm \bin – vpram86 Sep 11 '09 at 13:18
  • Fixed my problem by pointing the eclipse.ini to a 32 bit java jdk. – Taylor Leese Oct 02 '09 at 14:31
1

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?

Community
  • 1
  • 1
Abhijeet
  • 8,561
  • 5
  • 70
  • 76
1

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

João Quintas
  • 761
  • 2
  • 9
  • 18
0

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

Jolly1234
  • 1,577
  • 12
  • 9
0

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
Abdollah
  • 4,579
  • 3
  • 29
  • 49
-1

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.

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.

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
z8888q
  • 17
  • 3