While trying to build a project using intelliJ Ultimate 12 I am getting these errors
use -source or higher to enable diamond operator
use -source 7 or higher
For IntelliJ IDEA Community 2018.2:
You can also use F4 as shortcut to get to the same menu.
In addition to the accepted answer, you may also need to change the language level under Project Structure > Modules > Sources tab.
I also needed to change the java compiler being used at the IDE level under IntelliJ IDEA > Preference > Compiler > Java Compiler to 1.7 from 1.6. The exact location of the setting will vary based on your OS and version of IntelliJ IDEA.
I had the same problem and was struggling. Auto-import was true, re-import of project was not working and tried all possible options. But finally i found the solution.
"Reimport All Maven Projects" did the trick for me.
You can find the option on the Maven Project tab.
the language level for a project is set in the project structure dialog:
you want to make sure you set the language level to java 7, and the sdk accordingly
If using Gradle as a build automation, set following settings in build.gradle and re-import your project:
sourceCompatibility = 1.7
targetCompatibility = 1.7
None of the above worked for me.
I had to explicitly add the following plugin statement to my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
(Well, IDEA made it for me when I clicked the red help lamp and selected "Set project Java level to 7", so maybe try that if this also doesn't work).