1

I am using Java 8 for my JRE in Eclipse Luna with with the m2e Maven plugin. I see this warning as soon as I create a Maven project: Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment. I see lots of older advice on this site on how to deal with this error, but nothing related to Java 8. I also that Oracle says J2SE was deprecated in 2008. The most promising answer I have found thus far comes from @Pascal Thivent here:

Warning - Build path specifies execution environment J2SE-1.4

But these instructions no longer seem to be relevant for Luna:

Eclipse project Properties > Maven > Update Project Configuration

I only see "Lifecycle mapping" under Maven.

enter image description here

Can someone please explain (1) what this error means (2) if it is still a worry, given that J2SE-1.5 seems to have been deprecated (3) how to best fix it in Luna?

Community
  • 1
  • 1
bernie2436
  • 22,841
  • 49
  • 151
  • 244
  • I think you should update the POM first and then the m2e configuration for that project. (Probably something like this for Maven: http://maven.apache.org/enforcer/enforcer-rules/requireJavaVersion.html) – Gábor Bakos Jan 05 '15 at 21:47
  • Its because you don't a JRE 5 installed in Eclipse: `Prefereces > Java > Installed JREs` – Mike R Jan 05 '15 at 21:48
  • `Update Project Configuration` is in context menu of project in project panel under `maven` menu – msangel Jan 05 '15 at 21:50
  • 1
    change your installed jre to point to JDK 1.5 – jmj Jan 05 '15 at 22:03
  • @JigarJoshi but I need JRE 8 for some of the jars in my project – bernie2436 Jan 05 '15 at 22:04
  • 1
    ok then change your pom.xml to have compiler plugin to use 1.8 as source and target and change your installed JRE to point to JDk 1.8 – jmj Jan 05 '15 at 22:05
  • @JigarJoshi is this what I need to set in my pom.xml? http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html – bernie2436 Jan 05 '15 at 22:09

1 Answers1

2
  1. This error is because the project pom file is instructing maven to compile against java 1.5.
  2. It is best to compile and test to a current java version. In your case java 8.
  3. I am unsure how to fix it inside the eclipse IDE, but the project pom file can be edited to include the compile version as follows:

    <plugin>  
      <groupId>org.apache.maven.plugins</groupId>    
      <artifactId>maven-compiler-plugin</artifactId>    
      <version>3.1</version>    
      <configuration>    
        <source>1.8</source>    
        <target>1.8</target>    
      </configuration>    
    </plugin>
    
jmj
  • 237,923
  • 42
  • 401
  • 438
paddatrapper
  • 88
  • 1
  • 5