26

I keep getting this error even though I have a 1.6+ version (I have 1.8), and i'm working with IntelliJ.

P.S. I have tried to update both, java jre and java jdk, didn't help!

Renya Karasuma
  • 1,044
  • 4
  • 11
  • 18
  • This question may help. I solve same problem this way. http://stackoverflow.com/questions/24217611/make-intellij-idea-allow-lambda-in-java-5-6-7-language-level-with-ide-support – Blad Blue Shift Aug 17 '16 at 05:12

5 Answers5

55

File > Project Structure > Project Settings > Modules > your Module name > Sources > Language Level > choose the one which you need.

enter image description here

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
hexsmith
  • 576
  • 5
  • 3
4

This warning is produced by the Java | Java language level migration aids | Usages of API which isn't available at the configured language level inspection. By default this inspection looks at the language level configured for the project, and warns on any api used that was not available in the JDK version matching the language level. Most likely your project's or module's language level is not configured correctly in the Project Structure settings.

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68
  • I changed the language level in project structure, and idea remove its error message ! Thanks – Vouze Nov 03 '17 at 13:59
2

You may also need to ensure that your project has build/release set to the right java version. Without that, you may see an error like this:

Error:java: javacTask: source release 1.8 requires target release 1.8

The way to fix it for maven project is to enable build plugin in your pom file. This SO answer has specifics.

Community
  • 1
  • 1
ratbr
  • 121
  • 1
  • 5
0

If your project was imported via maven, you can fix the error by adding/editing the maven compiler plugin definition to look like this

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
</plugin>

But if you're collaborating on an open source project, then making such a change will need approval first. If it's denied then you can do what 余智平 suggested. But keep in mind that the setting may be reverted if you some how reimport the project as InteliJ will read project configurations again from the POM.

Stylishcoder
  • 1,142
  • 1
  • 11
  • 21
0

use below in your pom to set the java version which Intellij will be used(default is 1.5)

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>
yk42b
  • 179
  • 3
  • 15