Switch the Java runtime used to run IntelliJ IDEAFrom the main menu, select Help | Find Action or press Ctrl+Shift+A . Find and select the Choose Boot Java Runtime for the IDE action. Select the desired runtime and click OK.
Java 11 and IntelliJ IDEA.
From the main menu, select File | Project Structure Ctrl+Alt+Shift+S . Under Project Settings, select Modules | Sources. From the Language level list, select the necessary option.
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.
If nothing of this helps (my case), you can set it in your pom.xml, like this:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
As this cool guy mentioned here: https://stackoverflow.com/a/25888116/1643465
[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:
You might also want to take a look at Settings | Compiler | Java Compiler | Per-module bytecode version.
I believe that (at least in 2016.2): checking out different commits in git
resets these to 1.5.
Alternatively, you can apply maven-compiler-plugin with appropriate java version by adding this to your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
I tried making changes to Intellij IDEA as below:
1.
File >> Settings >> Build, Execution, Deployment >> Compiler >> Java Compiler >> project bytecode version: 1.8 >> Per-module bytecode version: 1.8
2.
File >> Project Structure >> Project Settings >> Project >> SDK : 1.8, Project Language : 8 - Lambdas
File >> Project Structure >> Project Settings >> Modules >> abc : Language level: 8 - Lambdas
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:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Option 2:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With