Solution:
File > Settings > Build, Execution, Deployment > Compiler > Java Compiler
Alter Target bytecode version to 1.8 of the module that you are performing for.
In case you are employing Maven
Include the compiler plugin to pom.xml
under the top-level project
node:
<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>
Note: In case you don't mind reimporting your project, then the just conceive you truly require to do is alter the pom and reimport the project, then IntelliJ will collect the right settings and you don't have to manually alter them.
This seems like the kind of error that Maven originates at the time you don't have the compiler plugin configured properly. Here's an instance of a Java 8 compiler config.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- ... -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<!-- ... -->
</project>
The quickest method I found:
First, Press:CTRL + SHIFT + A (For Mac ⌘ + SHIFT + A)
Then, type: java compiler
Lastly, press: ENTER
In the Settings window, fix the Target bytecode to 1.8
Like stated on the wiki page of the Apache Maven Compiler Plugin you can only fix the 2 properties employed by the plugin.
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
I solved this by going to Project Structure -> Modules, trace the module in question, click on Dependencies tab, alter Module SDK
to Project SDK
.