Reputation: 461
I set the JDK 11, it compiles until I use the new method of Java 11 isBlank()
of a String when I use that method this error appears when compiling, I tried cleaning the JDK installations, cleaning caches from IntelliJ, rebuilding but nothing helps. The error is:
Upvotes: 36
Views: 42240
Reputation: 8307
Set compiler target bytecode version to 11:
Settings
Build, Execution, Deployment
Compiler
Java compiler
Upvotes: 69
Reputation: 61
I had a similar problem. Got symbol not found for a Java 11 feature. Though everything was set to 11 already.
The solution was that in my Idea settings the Gradle JVM was set to JDK 8. (because I added JDK 11 later)
As sourceCompatibilty
and targetCompatibility
where not set in my build.gradle the gradle daemon (started from Idea) was running and compiling with JDK 8. These properties where dynamically set to 8 (or 1.8).
Telling Idea to set JVM for Gradle to 11 was my solution:
Upvotes: 6
Reputation: 2609
For my case, it was not even showing 11 in Project language level. So I had to choose X like below screenshot
Upvotes: 1
Reputation: 695
You should check following things:
And if you use Maven, check that your compiler plugin "source" and "target" properties in your pom.xml
are 11. Your module language level configuration is imported from that pom.xml
configuration in such a case
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
or
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
In case your pom.xml
had wrong source or target level you may need to do Right-click | Maven | Reimport after changing that pom.xml
. In case you use Gradle you should check that you have a similar configuration.
Tested with Maven 3.5.4 in IntelliJ IDEA 2018.2.4
Upvotes: 15
Reputation: 4486
You can use JDK 11 to compile but if you compile against an older version of java, it cannot find that method.
Go to File > Project Structure -> Project
and check the project language level as shown by the arrow in the picture below:
Not working with project language level 10:
Working fine with project language level 11:
Note that I have the following Java Compiler settings (default settings for a fresh new project using IntelliJ 2018.3):
The project bytecode version is same as language level!
Upvotes: 10