When packaging my project using maven in intellij idea, it gives below error, also my java compiler version is set on 1.8: diamond operator is not supported in -source 1.5 [ERROR] (use -source 7 or higher to enable diamond operator) I'm really confused, because both java version and compiler version are set with 1.8.
Asked
Active
Viewed 1.1k times
4
-
1It looks that you have the correct version in maven or Gradle but in your module settings is set to a lower version or vice-versa. Please check Module settings compiler version and your pom.xml or build.gradle – Mario Sep 27 '17 at 06:57
-
1`-source 1.5` means "only support language features from Java 1.5", no matter the compiler version – Clashsoft Sep 27 '17 at 07:21
-
1See also http://stackoverflow.com/a/12900859/104891. – CrazyCoder Sep 27 '17 at 09:38
1 Answers
13
Include the following within your <build>
tag of your pom.xml
to configure maven to compile with source and target with Java 1.8
:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>

Naman
- 27,789
- 26
- 218
- 353