IntelliJ/Gradle 无法从“11.0.1"确定 java 版本 [英] IntelliJ/Gradle Could not determine java version from '11.0.1'

查看:37
本文介绍了IntelliJ/Gradle 无法从“11.0.1"确定 java 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

通常,IntelliJ 建议您使用默认的 gradle 包装器.但就我而言,我希望能够在需要更新时即时更改 Gradle 版本.如果您在 Gradle 中使用 IntelliJ,并且遇到以下错误:

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:

Could not determine java version from '11.0.1'

推荐答案

如果你使用 IntelliJ

If you use IntelliJ

检查:

  1. 导航到:

  1. Navigate to:

<代码>文件 >>设置 >>构建、执行、部署 >>构建工具 >>摇篮.

Gradle JVM 一起:确保您选择了正确的 Java 版本.

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

导航到:右键单击项目根目录"&选择打开模块设置.Project Structure 窗口出现.确保您的 JDK 主路径已添加到 Platform Settings >>SDKs : JDK 主路径

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

仍然在同一窗口Project Structure,在

项目设置>>模块:模块SDK

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

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

我的最新版本是:

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

如下图:

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

In your build.gradle file make sure you set:

sourceCompatibility = 11

这篇关于IntelliJ/Gradle 无法从“11.0.1"确定 java 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆