Search code examples
javamavenintellij-idea

How to change Java version for Maven in IntelliJ?


I'm new to both Maven and IntelliJ IDEA.

I have a Maven project written in Java 8. Whenever I try to build it (Maven Projects window -> Lifecycle -> compile -> Run Maven Build) I get a series of compilation errors:

[ERROR] path/to/file.java:[26,52] lambda expressions are not supported in -source 1.5
(use -source 8 or higher to enable lambda expressions)

Where am I supposed to change the value of the -source parameter? I tried adding it as an additional parameter in Settings -> Compiler - > Java Compiler, but I got the same results.

The project's and module's language levels are both set to 8.0.

I'm using Maven 3.2.3 and IntelliJ IDEA Community Edition 13.1.2.


Solution

  • Or easier, add this to your pom's properties section:

    <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
    </properties>