Posts Tagged ‘java maven eclipse’

Maven Integration with Eclipse

Sunday, October 24th, 2010

Install m2eclipse. See instructions on http://maven.apache.org/eclipse-plugin.html.

By default, Eclipse uses the JRE as the default Java environment. When you try to create a new Maven project, you will get the following message:



The Maven Integration requires that Eclipse be running in a JDK, because a number of Maven core plugins are using jars from the JDK.


Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that Installed JREs are also using JDK installs.


My JDK is installed here:

C:\Program Files\Java\jdk1.6.0_22

To resolve this, first set the JDK as the default Java environment for eclipse. It is set under Window -> Preferences -> Java -> Installed JREs. Click on the thumbnail below for a screenshot.

Set JDK as default Java environment in Eclipse

Next, add the following to eclipse.ini:

-vm
C:\Progra~1\Java\jdk1.6.0_22\bin\javaw.exe

Some notes on the -vm option:

  • The path to the JDK must be on the line below the “-vm”.
  • The path to the JDK cannot have any spaces. Enclosing the the path in quotes will not work.
  • If there are spaces in the path to the JDK, then shorten using the tilde. For example “Program Files” needs to be shortened to “Progra~1″.
  • The “-vm” option must be placed before the “-vmargs” option.

Below are the contents of my eclipse.ini:

-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:\Progra~1\Java\jdk1.6.0_22\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m