Eclipse Maven | lambda | use -source 8 or Higher to enable lambda Expressions

Asked

Viewed 337 times

1

Java Maven project in Eclipse neon (4.6.0), simply does not compile when using lambda.

The mistake:

use lambda Expressions are not supported in -source 1.5 (use -source 8 or Higher to enable lambda Expressions)

The detail is I’m using JDK 8:

java version "1.8.0_101" Java(TM) SE Runtime Environment (build 1.8.0_101-B13) Java Hotspot(TM) 64-Bit Server VM (build 25.101-B13, Mixed mode)

Eclipse is also configured correctly according to the images below:

inserir a descrição da imagem aqui inserir a descrição da imagem aqui inserir a descrição da imagem aqui inserir a descrição da imagem aqui Any idea why there’s a lambda error?

1 answer

1


The code of your pom.xml should also reference java8. It would look like this:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
  • It worked, but I’d never had to do it, you know why? Thank you.

  • Yes, every time you build the Maven project it changes the version of the java you selected. That’s why you always need to report this in the pom.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.