Reputation: 3344
I' trying to build a in IntelliJ IDEA project that is not mine and I got the following error:
java: diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator)
How do I change this setting in IntelliJ IDEA?
Upvotes: 53
Views: 75851
Reputation: 2664
File->Project structure->Project Settings->Modules->Language level
Change level using drop down.
Otherwise, If you are using maven for build,
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 10
Reputation: 506
For me, above answers didn't work, although they helped me solve my issue. At module level build.gradle
do the following:
compileOptions {
// I've changed below values from VERSION_1_6 to VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
Upvotes: 1
Reputation: 953
And, if you're working with a maven project, for sanity, remember to set the java version in the pom too.
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 22
Reputation: 2695
For me, changing the Language Level in Project Structure and restarting IDEA didn't help.
I had to edit the build.gradle
in core
module and change the source compatibility from 1.6 to 1.7:
apply plugin: "java"
sourceCompatibility = 1.7 //changed from 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-core"
}
Build -> Clean Project
Upvotes: 6
Reputation: 6882
I know the OP uses IntelliJ IDEA, but Android Studio is based on IntelliJ IDEA, so I wanna say one more word.
If you use Android Studio, command+;
(for Mac) or File->Project Structure
, then in the open window follow the settings:
Upvotes: 25
Reputation: 19000
Ctrl+Alt+Shift+S (Project Structure icon)
Then change Project language level
Upvotes: 73
Reputation: 5259
File -> Project Structure -> Sources -> Language level
You will have to reload IDEA
Upvotes: 17