IntelliJ IDEA 13 uses Java 1.5 despite setting to 1.7

PNS picture PNS · Jan 8, 2014 · Viewed 100.3k times · Source

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?

Answer

Peter Gromov picture Peter Gromov · Jan 8, 2014

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.