Can't use latest Java Version (JDK 21) in IntelliJ IDEA
05:36 20 Sep 2023

I'm using macOS and I want to try Java 21 in IntelliJ IDEA. I believe I have done all the required steps to change Java version of a project / module. Nevertheless I still can't use new Java 21 Features, such as String Templates. How to be able to use Java 21 in IntelliJ?

enter image description here

I have changed:

  • Project SDK to 21

  • Module SDK to 21

  • OS java version to 21. Typing java -version in terminal outputs:

    java version "21" 2023-09-19 LTS

    Java(TM) SE Runtime Environment (build 21+35-LTS-2513)

    Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)

  • I have also updated IntelliJ to version 2023.2

java intellij-idea sdk java-21