IntelliJ IDEA 2019 runs Java 11 (when building Gradle project) even though every option set to Java 8?

Viewed 6454

When attempting to import a Gradle project, I receive the following error:

Cannot determine classpath for resource 'java/sql/SQLException.class' from location 'jrt:/java.sql/java/sql/SQLException.class'.

The project uses Gradle 2.14 which is incompatible with IDEA running on Java 10 or newer.
See details at https://github.com/gradle/gradle/issues/8431
Possible solution:
 - Upgrade Gradle wrapper to 4.8.1 version and re-import the project

While there are already posted solutions to this error, I have tried them all without any success. Namely, I've tried:

  • File > Project Structure > Project > Project SDK > 1.8 (java version "1.8.0_231")
  • File > Project Structure > Project > Project language level > SDK default (8)
  • File > Project Structure > Modules > (ensure that every applicable Module SDK and Language level were set correctly)
  • File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM > Use Project JDK (1.8.0_231)
  • File > Settings > Build, Execution, Deployment > Compiler > Project bytecode version > 8
  • File > Other Settings > Project Structure for New Projects > Project Settings > Project > Project SDK > 1.8

...all to no avail.

2 Answers

IntelliJ IDEA itself is running on Java 11 by default. See this document for details.

The issue is about the Gradle Tooling API not compatible with the IDE running on Java 11.

The workaround is to switch the IDE runtime to 1.8 or upgrade to Gradle 4.8.1+.

Other IntelliJ IDEA Versions page has the links to IDE versions bundled with JBR8 instead of JBR11.

Related