7

I have maven project opened in Eclipse. But when I do clean and install, I get above error.

I changed my build path to use SE 1.8 and my compiler is also configured to use 1.8. You can see that in following screen shots.

enter image description here

enter image description here

I am seeing little red crosses in project explorer too. You can see that in following picture.

enter image description here

I am not sure why maven is using SE 1.7 when I have configured it to use 1.8 in Eclipse.

Darshan Puranik
  • 1,055
  • 3
  • 14
  • 36
  • Look into your pom.xml. Maybe there is the target version set to java 1.7. If you do not see it, please provide the content of the file – Jens Jan 24 '17 at 08:33
  • Please see [here](http://stackoverflow.com/questions/29888592/errorjava-javactask-source-release-8-requires-target-release-1-8/30524848#30524848) – Aaric Chen Jan 24 '17 at 09:55

1 Answers1

29

You need to configure maven to use 1.8 compatibility when compiling:

    <build>
      <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <encoding>utf8</encoding>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
     </plugins>
   </build>
marthursson
  • 3,242
  • 1
  • 18
  • 28
  • It worked!! Thanks. I still have those red crosses in my project explorer and they really bug me. – Darshan Puranik Jan 24 '17 at 08:41
  • 1
    I had to do Maven Update and that annoying crosses went away. – Darshan Puranik Jan 24 '17 at 08:48
  • 2
    where I can see this file to edit? – mboy Jan 16 '19 at 06:27
  • What is the version? I am getting this error when pushing code to heroku. `'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing.` Edit: Seems like the correct version is 3.8.1 looking off this link https://maven.apache.org/plugins/. The code build still is crashing but I think that is an unrelated problem – Matt Jun 18 '21 at 04:00