简体   繁体   中英

IntelliJ Using Wrong JDK - Execution failed for task ':compileJava'. > invalid source release: 11

My project runs on the command line but fails to run in IntelliJ. I've tried all of the solutions in the following questions:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

However I did notice that Gradle is compiling the project with the wrong JDK

Does anyone know why InteliJ is not using the JDK I defined?

在此处输入图像描述

I also tried overriding JAVA_HOME

在此处输入图像描述

Configure IntelliJ IDEA Gradle JDK: Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM.

摇篮JVM

Finally, this worked for me:

  1. Close IntelliJ
  2. On the command line, run sdk default java 11.0.11.9.1-amzn
  3. Restart IntelliJ
  4. Rerun the app within IntelliJ

在此处输入图像描述

Note:

I'm still interested to know how to override the SDKMAN setting within IntelliJ. If anyone knows, please adda comment or answer. Thanks!

USE SDKMAN to install the java versions. configure the installed sdks into IntelliJ and use the appropriate one for the project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM