I am running IntelliJ on a Mac M2 architecture. I initially downloaded JDK 17 from Adopt Open JDK and created a simple Kotlin project that prints "hello world" from provided sample code within the IDE as shown below:
However, I am getting this error message when trying to build this simple hello world project:
Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
Unable to download toolchain matching these requirements: {languageVersion=8, vendor=any, implementation=vendor-specific}
Unable to download toolchain. This might indicate that the combination (version, architecture, release/early access, ...) for the requested JDK is not available.
Could not read 'https://api.adoptopenjdk.net/v3/binary/latest/8/ga/mac/aarch64/jdk/hotspot/normal/adoptopenjdk' as it does not exist.
The error message is definitely true as when I copy and paste the URL:
https://api.adoptopenjdk.net/v3/binary/latest/8/ga/mac/aarch64/jdk/hotspot/normal/adoptopenjdk
and put in a web browser, the site does not exist. So it makes sense why IntelliJ can't read the site.
So I downloaded the Oracle JDK 17 for M2 Apple instead and pointed the IntelliJ project to look at where it was installed as shown below:
However, IntelliJ seems to be stuck on using Adopt Open JDK despite the fact that I'm telling it to use Oracle JDK 17. How do I get IntelliJ to use the Oracle JDK and look for the Adopt JDK instead?
It's a known issue.
The solution is to either update to IntelliJ IDEA 2023+ (currently available as RC) or to change jvmToolchain(8)
in build.gradle.kts
to jvmToolchain(11)
.