I'm on OSx (El Capitain) and I have Java 8 running
> ${JAVA_HOME}/bin/java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
As outlined in this separate answer, I needed to my java version to maven using the maven compiler plugin.
So I added the below to pom.xml
, using the jdk.version
placeholder
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</build>
However, I'm stilling getting the below error when running mvn jetty:run
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project spark-example: Compilation failure
[ERROR] /Users/abhishek/git/abhishek/spark-example/src/main/java/Main.java:[5,34] lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
I'm aware I could hard-code 1.8
in place of the jdk.version
, but I feel like I've seen this used without issue in other projects.
Is there something I'm missing there, or any specific reason this doesn't work?
Thanks!
I think that you want to use the property ${jdk.version}, but it was not defined in pom.
Try to add code below in you pom.xml:
<properties>
<jdk.version>1.8</jdk.version>
</properties>
Please refer to properties in pom.