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
IntelliJ/Gradle Could not determine java version from '11.0.1'
提问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:
检查:
Navigate to:
File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle
.Alongside
Gradle JVM:
make sure you select the correct version of Java.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 thePlatform Settings >> SDKs : JDK home path
Still, on the same window
Project Structure
, select correct SDK relevant to your project underFix/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:
In your build.gradle file make sure you set:
sourceCompatibility = 11
导航:
File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle
.导航至:右键单击“项目根目录”并选择
Open Module Settings
。Project Structure
窗口显示。确保您的 JDK 主路径已添加到Platform Settings >> SDKs : JDK home path
仍然,在同一个窗口中
Project Structure
,选择与您的项目相关的正确 SDK修复/解决方案:导航至&打开:
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
如下所示:
在你的 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
有关详细信息,请参阅此图片
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
回答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
- OPENthe Action Dialog
- 打开操作对话框
- SEARCH: switch boot jdk
- 搜索:切换启动jdk
- SELECTthe JDK installed by you rather than the intellij default
- 选择你安装的JDK而不是intellij默认的
HOPE this solution is work for you .
希望此解决方案适合您。
回答by Fox user9219598
check , maybe you have 2 times gradle in path
检查,也许你在路径中有 2 次 gradle