How to compile in Java 8 using Maven

By default maven doesn't compile code in the JVM level. The code level can be passed to the compiler using properties.



If the compiler cannot compile the code due to compatibility issue like using Lambda expressions with Java 5 compatibility, the following error will be returned:

ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project project: Compilation failure
[ERROR] /PATH/[62,29] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
[ERROR] -> [Help 1]

use source 8 or higher to enable lambda expressions



Recent Comments