I have written code which can compile on Java 1.8 (try block). It is compiled and running for me when I run it directly. While I am trying to build it using Maven in my local, I am facing an issue which is saying to use -source 7 or later. I tried all possible ways to use java 8 and all places I have specified 8 only but Maven is trying to compile using java 1.6 it seems.
Can any one you please help me where can I correct it to pick my maven to use java 1.8.
Thanks, Venkat
Following should work too:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
You can specify that using the maven-compiler-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0<</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Just remember to use the newest version of the plugin.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.