Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK
), the following error is produced by IntelliJ 13
when trying to compile some simple Java 7 code which does use the diamond operator:
java: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
Is there any other place in the configuration where the expected -source 7
option should be enabled?
I tried making changes to Intellij IDEA as below:
1.
2.
but nothing worked, it reverted the versions to java 1.5 as soon as I saved it.
However, adding below lines to root(project level) pom.xml worked me to resolve above issue: (both of the options worked for me)
Option 1:
Option 2:
[For IntelliJ IDEA 2016.2]
I would like to expand upon part of Peter Gromov's answer with an up-to-date screenshot. Specifically this particular part:
I believe that (at least in 2016.2): checking out different commits in
git
resets these to 1.5.First, you need to change the "project bytecode version" under
File > Settings
,Compiler > Java Compiler
Second, do a full rebuild.
Please check your project/module language levels (Project Structure | Project; Project Structure | Modules | module-name | Sources). You might also want to take a look at Settings | Compiler | Java Compiler | Per-module bytecode version.
Set also this:
File -> Project Structure -> Modules :: Sources (next to Paths and Dependencies) and that has a "Language level" option which also needs to be set correctly.