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!
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!
File
> Project Structure
> Project Settings
> Modules
> your Module name
> Sources
> Language Level
> choose the one which you need.
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.
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.
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.
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>