简体   繁体   English

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

[英]IntelliJ/Gradle Could not determine java version from '11.0.1'

I'm running a Linux Ubuntu 18 OS.我正在运行 Linux Ubuntu 18 操作系统。 Installed jdk in a custom local directory.在自定义本地目录中安装 jdk。

Normally, IntelliJ recommends that you use the default gradle wrapper .通常,IntelliJ 建议您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.但就我而言,我希望能够在需要更新时即时更改 Gradle 版本。 If you use IntelliJ with Gradle, and you bump into the following error:如果您将 IntelliJ 与 Gradle 一起使用,则会遇到以下错误:

Could not determine java version from '11.0.1'

If you use IntelliJ如果你使用 IntelliJ

Checks:检查:

  1. Navigate to:导航:

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

    Alongside Gradle JVM: make sure you select the correct version of Java.除了Gradle JVM:确保选择正确的 Java 版本。 摇篮JVM

  2. Navigate to: Right-Click 'Project Root Directory' & Select Open Module Settings .导航至:右键单击“项目根目录”并选择“ Open Module Settings Project Structure windows shows-up. Project Structure窗口显示。 Make sure your JDK home path is added to the Platform Settings >> SDKs : JDK home path确保您的 JDK 主路径已添加到Platform Settings >> SDKs : JDK home path 项目结构>>平台设置>>SDKs:JDK主路径

  3. Still, on the same window Project Structure , select correct SDK relevant to your project under仍然,在同一个窗口Project Structure ,选择与您的项目相关的正确 SDK

    Project Settings >> Modules : Module SDK 模块SDK

  4. Fix/Solution: Nvavigate to & open: gradle/wrapper/gradle-wrapper.properties & update the distributionUrl version to the latest version.修复/解决方案:导航至并打开: gradle/wrapper/gradle-wrapper.properties并将 distributionUrl 版本更新为最新版本。 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 版本更新

  5. In your build.gradle file make sure you set:在你的 build.gradle 文件中确保你设置:

    sourceCompatibility = 11

If you are using the latest version of intellijIdea.如果您使用的是 IntellijIdea 的最新版本。

In my case, 2019.1 -version就我而言, 2019.1 -version

Delete the directory idea's jdk删除目录idea的jdk

then RESTART idea.然后重新启动想法。

for detail see this pic详情见这张照片

在此处输入图片说明

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就可以如下图。

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

I noticed a subtlety in the way you download the IDE from jetbains.com我注意到您从 jetbains.com 下载 IDE 的方式有些微妙

jetbrains.com 的屏幕截图

You probably want JBR 8 and not JBR 11. Also, make sure your JDK is setup properly with jbsdk bintray downloader plugin.您可能需要 JBR 8 而不是JBR 11。另外,请确保您的 JDK 已使用 jbsdk bintray 下载器插件正确设置。

I recently upgraded my Ubantu to 18 from 16. After that I am facing this issue.我最近将我的 Ubantu 从 16 升级到 18。之后我面临这个问题。 Problem was during ubantu upgrade java is automatically upgraded to 11 from 8. Hence getting this error.问题是在 ubantu 升级期间,java 会自动从 8 升级到 11。因此出现此错误。 You can simply downgrade jdk using this to solve this.您可以使用简单地降级 jdk 来解决这个问题。 Works for me.为我工作。

Reintalling Intellij Worked for me.重新安装 Intellij 对我有用。 You need to uninstall first before reinstall.在重新安装之前,您需要先卸载。 While uninstalling, ensure to select option to delete older cache and settings卸载时,确保选择删除旧缓存和设置的选项

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

MODIFY default Boot JDK修改默认引导JDK

  1. OPEN the Action Dialog打开操作对话框

在此处输入图片说明

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

在此处输入图片说明

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

在此处输入图片说明

  1. RESTART intellij idea重启智能理念

  2. IGNORE this popup at right-bottom on IDE忽略IDE 右下角的这个弹出窗口在此处输入图片说明

HOPE this solution is work for you .希望此解决方案适合您。

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

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