Search code examples
javaeclipsescalamavenm2eclipse

Eclipse Maven update causes corruption of JVM setting


I have a scala project setup that uses maven (running on OSX, Juno). For some inexplicable reason running a m2e update causes the JVM to be changed to 1.7 JRE (which doesn't exist on my system, and is unset).

In particular, this seems to happen when I import the project into eclipse (after first generating the project via sbt):

in .classpath

<classpathentry path="org.eclipse.jdt.launching.JRE_CONTAINER" kind="con"></classpathentry>

Gets changed to:

<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>

org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7 doesn't exist (the system has 1.6).

Sounds like m2e is writing this, but I can't seem to locate how / why, and where I could change this setting.


Solution

  • Your POM might contain something like

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
    

    which will cause m2e to update your project to use Java 7. Change <source>1.7</source> to <source>1.6</source> (and of course, the same holds for <target>), and you should be ready to go.