Maven/Eclipse: Build path specifies execution environment J2SE-1.5

April 6th, 2009 by  |  Published in Maven  |  3 Comments

After running `mvn eclipse:eclipse` this morning, we got a warning from eclipse, telling us that “Build path specifies execution environment J2SE-1.5. There are no JREs in the workspace strictly compatible with this environment.” We didn’t make any changes that could cause this warning, though. We deceided to leave the problem as it was and fix it later – it’s only a warning anyway. However, when trying to start another project, I got another exception I haven’t ever received before. It was caused by mixing up wrong versions of different slf4j JARs.

I suddenly had the feeling that ther’s something fishy with the maven-eclipse-plugin. And in deed, a look into the ~/.m2/repository/org/apache/maven/plugins/maven-eclipse-plugin proved me right. There is a brand new version 2.6 of the plugin.

This new version automagically adds projects from the workspace rather than JARs from the local repository (which is cool, basically). However, that caused Eclipse to load the wrong JARs: One project depended on sl4j 1.3, another one on 1.5 and the other project. Maven perfectly resolves the version of this transient depenedency, while Eclipse picks one by chance. Gotcha#1!

The first warning was caused by maven-compiler-plugin beeing configured to compile for Java 1.5 while only a 1.6 JDK was available. Gotcha#2!

Hopefully this post will save other people from being as clueless as I’ve been 😉

Responses

  1. Stephen says:

    February 7th, 2013 at 6:28 pm (#)

    Is it possible to get Eclipse to force maven to look for a specific JRE?

    Maven keeps compiling my project back to 1.5 instead of using the one that I want which is 1.6.

    Thoughts?

    Thanks!

  2. Anonymous says:

    July 11th, 2013 at 2:45 am (#)

    See:

    http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

    for the answer.

  3. Kuletzxc says:

    March 6th, 2014 at 2:35 pm (#)

    Try this ! In Eclipse,
    your project
    -> properties
    -> java build path : Libraries
    Remove the “JRE System Library[J2SE 1.4]”
    -> click “Add Library” button -> JRE System Library
    -> select the new “Executin Environment” or Workspace default JRE

Leave a Response