IntelliJ/Gradle 无法从“11.0.1”确定 java 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/54507225/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 01:04:11  来源:igfitidea点击:

IntelliJ/Gradle Could not determine java version from '11.0.1'

javagradleintellij-ideabuild.gradleversion

提问by S34N

I'm running a Linux Ubuntu 18 OS. Installed jdk in a custom local directory.

我正在运行 Linux Ubuntu 18 操作系统。在自定义本地目录中安装 jdk。

Normally, IntelliJ recommends that you use the default gradle wrapper. But in my case, I want to be able to change the Gradle Version on the fly whenever it's due for an update. If you use IntelliJ with Gradle, and you bump into the following error:

通常,IntelliJ 建议您使用use the default gradle wrapper. 但就我而言,我希望能够在需要更新时即时更改 Gradle 版本。如果您将 IntelliJ 与 Gradle 一起使用,则会遇到以下错误:

Could not determine java version from '11.0.1'

采纳答案by S34N

If you use IntelliJ

如果你使用 IntelliJ

Checks:

检查:

  1. Navigate to:

    File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle.

    Alongside Gradle JVM:make sure you select the correct version of Java. Gradle JVM

  2. Navigate to: Right-Click 'Project Root Directory' & Select Open Module Settings. Project Structurewindows shows-up. Make sure your JDK home path is added to the Platform Settings >> SDKs : JDK home pathProject Structure >>Platform Settings >>SDKs : JDK home path

  3. Still, on the same window Project Structure, select correct SDK relevant to your project under

    Project Settings >> Modules : Module SDKModule SDK

  4. Fix/Solution: Nvavigate to & open: gradle/wrapper/gradle-wrapper.properties& update the distributionUrl version to the latest version. In my case (at the time of this post), my older version was:

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

    And my latest version is:

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip

    As shown below:

    distributionUrl Version Update

  5. In your build.gradle file make sure you set:

    sourceCompatibility = 11

  1. 导航:

    File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle.

    同时Gradle JVM:确保您选择了正确的 Java 版本。 摇篮JVM

  2. 导航至:右键单击“项目根目录”并选择Open Module SettingsProject Structure窗口显示。确保您的 JDK 主路径已添加到Platform Settings >> SDKs : JDK home path项目结构>>平台设置>>SDKs:JDK主路径

  3. 仍然,在同一个窗口中Project Structure,选择与您的项目相关的正确 SDK

    Project Settings >> Modules : Module SDK模块SDK

  4. 修复/解决方案:导航至&打开:gradle/wrapper/gradle-wrapper.properties&将 distributionUrl 版本更新为最新版本。就我而言(在撰写本文时),我的旧版本是:

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

    我的最新版本是:

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip

    如下所示:

    distributionUrl 版本更新

  5. 在你的 build.gradle 文件中确保你设置:

    sourceCompatibility = 11

回答by deFreitas

Your gradle is too old for that JDK, upgrade your gradle or downgrade you JDK

你的 gradle 对于那个 JDK 来说太旧了,升级你的 gradle 或者降级你的 JDK

回答by anKotliner

If you are using the latest version of intellijIdea.

如果您使用的是 IntellijIdea 的最新版本。

In my case, 2019.1 -version

就我而言, 2019.1 -version

Deletethe directory idea's jdk

删除目录idea的jdk

then RESTARTidea.

然后重新启动想法。

for detail see this pic

有关详细信息,请参阅此图片

enter image description here

在此处输入图片说明

Hope this is working for you !

希望这对你有用!

In chinese:

用中文(表达:

(If you can't read chinese,you needn't to read this.All you need to know have typed above already)

(如果你看不懂中文,你不需要读这个。所有你需要知道的已经在上面输入了)

如果你是用最新版本的intellijidea.由于intellijidea默认安装了11的java。而且就算你输入java -verison,告诉你是java8,在ide里面也配置了java 8 idea还是告诉你这个错误。

如果你是用最新版本的intellijidea。因为intellijidea默认安装了11的java。而且你输入java -verison,告诉你是java8,在ide里面也配置了java 8 idea还是告诉你这个错误。

只有通过删除idea自己下载java11版本,可以解决这个问题。直接删除应用包下的jdk文件夹,重启idea就可以。如下图。

只有通过删除idea自己下载java11版本,才能解决这个问题。直接删除应用包下的jdk文件夹,重启idea就可以如下图。

回答by Brooks DuBois

I noticed a subtlety in the way you download the IDE from jetbains.com

我注意到您从 jetbains.com 下载 IDE 的方式有些微妙

screenshot of jetbrains.com

jetbrains.com 的屏幕截图

You probably want JBR 8 and notJBR 11. Also, make sure your JDK is setup properly with jbsdk bintray downloader plugin.

您可能需要 JBR 8 而不是JBR 11。另外,请确保您的 JDK 已使用 jbsdk bintray 下载器插件正确设置。

回答by user3066038

Reintalling Intellij Worked for me. You need to uninstall first before reinstall. While uninstalling, ensure to select option to delete older cache and settings

重新安装 Intellij 对我有用。在重新安装之前,您需要先卸载。卸载时,确保选择删除旧缓存和设置的选项

回答by Niket Shah

I recently upgraded my Ubantu to 18 from 16. After that I am facing this issue. Problem was during ubantu upgrade java is automatically upgraded to 11 from 8. Hence getting this error. You can simply downgrade jdk using thisto solve this. Works for me.

我最近将我的 Ubantu 从 16 升级到 18。之后我面临这个问题。问题是在 ubantu 升级期间,java 会自动从 8 升级到 11。因此出现此错误。您可以使用简单地降级 jdk来解决这个问题。为我工作。

回答by anKotliner

MODIFY default Boot JDK

修改默认引导JDK

  1. OPENthe Action Dialog
  1. 打开操作对话框

enter image description here

在此处输入图片说明

  1. SEARCH: switch boot jdk
  1. 搜索:切换启动jdk

enter image description here

在此处输入图片说明

  1. SELECTthe JDK installed by you rather than the intellij default
  1. 选择你安装的JDK而不是intellij默认的

enter image description here

在此处输入图片说明

  1. RESTARTintellij idea

  2. IGNOREthis popup at right-bottom on IDE enter image description here

  1. 重启智能理念

  2. 忽略IDE 右下角的这个弹出窗口 在此处输入图片说明

HOPE this solution is work for you .

希望此解决方案适合您。

回答by Fox user9219598

check , maybe you have 2 times gradle in path

检查,也许你在路径中有 2 次 gradle