简体   繁体   English

IntelliJ 使用错误的 JDK - 任务“:compileJava”执行失败。 > 无效的源版本:11

[英]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.我的项目在命令行上运行,但无法在 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但是我确实注意到 Gradle 正在使用错误的 JDK 编译项目

Does anyone know why InteliJ is not using the JDK I defined?有谁知道为什么 InteliJ 不使用我定义的 JDK?

在此处输入图像描述

I also tried overriding JAVA_HOME我也尝试过覆盖 JAVA_HOME

在此处输入图像描述

Configure IntelliJ IDEA Gradle JDK: Settings (Preferences on macOS) |配置 IntelliJ IDEA Gradle JDK:设置(macOS 上的首选项)| Build, Execution, Deployment |构建、执行、部署 | Build Tools |构建工具 | Gradle | Gradle | Gradle JVM. Gradle JVM。

摇篮JVM

Finally, this worked for me:最后,这对我有用:

  1. Close IntelliJ关闭 IntelliJ
  2. On the command line, run sdk default java 11.0.11.9.1-amzn在命令行上,运行sdk default java 11.0.11.9.1-amzn
  3. Restart IntelliJ重启 IntelliJ
  4. Rerun the app within IntelliJ在 IntelliJ 中重新运行应用程序

在此处输入图像描述

Note:笔记:

I'm still interested to know how to override the SDKMAN setting within IntelliJ.我仍然很想知道如何覆盖 IntelliJ 中的 SDKMAN 设置。 If anyone knows, please adda comment or answer.如果有人知道,请添加评论或回答。 Thanks!谢谢!

USE SDKMAN to install the java versions.使用 SDKMAN 安装 java 版本。 configure the installed sdks into IntelliJ and use the appropriate one for the project将已安装的 sdks 配置到 IntelliJ 中并为项目使用合适的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 任务 ':compileJava' 执行失败。 > 无效的源版本:1.7 - Execution failed for task ':compileJava'. > invalid source release: 1.7 gradlew appengineEndpointsInstallClientLibs有错误执行失败的任务':compileJava'。 >无效的源版本:1.7 - gradlew appengineEndpointsInstallClientLibs has error Execution failed for task ':compileJava'. > invalid source release: 1.7 Intellij Idea - Gradle:任务执行失败':compileJava' - Intellij Idea - Gradle: Execution failed for task ':compileJava' 如何修复“任务 'compileJava' 执行失败”错误。 (使用 Intellij Idea 和 Gradle) - How do I fix “Execution failed for task 'compileJava'” error. (Using Intellij Idea and Gradle) 任务 ':compileJava' 执行失败。 摇篮 - Execution failed for task ':compileJava'. Gradle 任务 ':compileJava' 执行失败。 - 本系列第 3 期 - Execution failed for task ':compileJava'. - Issue 3 in this series 使用 ./gradlew run 执行任务 ':app:compileJava' 失败 - Execution failed for task ':app:compileJava' with ./gradlew run 错误:java:错误:源代码版本无效:13 使用带有 IntelliJ 的 JDK12 - Error:java: error: invalid source release: 13 using JDK12 with IntelliJ 错误:等级:任务':core:compileJava'的执行失败。 >编译失败 - Error:Gradle: Execution failed for task ':core:compileJava'. > Compilation failed 错误:等级:任务':core:compileJava'的执行失败。 图书馆 - Error:Gradle: Execution failed for task ':core:compileJava'. LIBGDX
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM