无法使用可执行文件 C:\Program Files\Java\jdk-10.0.1\bin\java.exe 确定 Java 版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50121333/
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-10 23:27:06  来源:igfitidea点击:

Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe

javaintellij-idea

提问by Mike Lin

Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe.

无法使用可执行文件 C:\Program Files\Java\jdk-10.0.1\bin\java.exe 确定 Java 版本。

This error appeared when I tried to create a new project in IntelliJ IDEA Version 2018.1.2 with Gradle. It said:

当我尝试使用 Gradle 在 IntelliJ IDEA 版本 2018.1.2 中创建一个新项目时出现此错误。它说:

sync failed: Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe

同步失败:无法使用可执行文件 C:\Program Files\Java\jdk-10.0.1\bin\java.exe 确定 Java 版本

==================

==================

I fixed the problem by uninstalling jdk 10 and installing jdk8.

我通过卸载 jdk 10 并安装 jdk8 解决了这个问题。

回答by JavaCafe01

It's most likely your gradle version. Gradle 4.7+ has JDK 10 support.

这很可能是您的 gradle 版本。Gradle 4.7+ 支持 JDK 10。

回答by Vijay Gurunanee

i had to un-install my intelliJ along with cache and all histories, remove my project... Then i re-installed intellij and downloaded my project's fresh version again.

我不得不卸载我的 intelliJ 以及缓存和所有历史记录,删除我的项目......然后我重新安装了 intellij 并再次下载了我的项目的新版本。

As a last step, i had to define new sdk for my project. Previously, it was showing 2-3 SDKs. after re-installation, there were none. i added one. To add SDK in Intellij: Go to- File- Project Structure- Project Settings- Project SDK...

作为最后一步,我必须为我的项目定义新的 sdk。以前,它显示 2-3 个 SDK。重新安装后,没有了。我加了一个。在 Intellij 中添加 SDK:转到-文件-项目结构-项目设置-项目 SDK...

Added one sdk here to point to the jdk installed path.

这里添加了一个sdk,指向jdk安装路径。

回答by Luka Lopusina

For JDK 10 you will need Gradle 4.7+ which is not used by default in IntelliJ IDEA (current version IntelliJ IDEA 2018.1.4).

对于 JDK 10,您将需要 Gradle 4.7+,它在 IntelliJ IDEA(当前版本 IntelliJ IDEA 2018.1.4)中默认不使用。

To fix this issue install latest Gradle for your OS (Install guide). For MacOS you can use Homebrew:

要解决此问题,请为您的操作系统安装最新的 Gradle(安装指南)。对于 MacOS,您可以使用 Homebrew:

brew install gradle

Go to your project directory:

转到您的项目目录:

cd ~/path/to/your/project/

Generate Gradle Wrapper script with the version you installed (in my case it is 4.8):

使用您安装的版本生成 Gradle Wrapper 脚本(在我的例子中是 4.8):

gradle wrapper --gradle-version 4.8

This command is going to download Gradle 4.8, create scripts gradlew and gradlew.bat for your current project. From this point, you should use these scripts in the command-line.

此命令将下载 Gradle 4.8,为您当前的项目创建脚本 gradlew 和 gradlew.bat。从这一点来看,您应该在命令行中使用这些脚本。

Next step, is to make sure that IntelliJ IDEA uses those, instead of built-in Gradle distribution and you can do this by opening IntelliJ preferences and search for "gradle" (this will be in "Build, Execution, Deployment / Build Tools / Gradle").

下一步,是确保 IntelliJ IDEA 使用这些,而不是内置的 Gradle 发行版,您可以通过打开 IntelliJ 首选项并搜索“gradle”(这将在“构建、执行、部署/构建工具/摇篮”)。

In this section of the settings select:

在设置的这一部分中选择:

Select “Use gradle ‘wrapper' task configuration”

选择“使用 gradle 'wrapper' 任务配置”

Apply changes, press ok and re-build (re-sync) Gradle and everything should be fine. I hope this helps.

应用更改,按确定并重新构建(重新同步)Gradle,一切都应该没问题。我希望这有帮助。

回答by Nafeez Quraishi

Below is what i did to solve this issue on Windows 10 with IntelliJ 2018.1.5 and Java 10.0.1 JDK

以下是我使用 IntelliJ 2018.1.5 和 Java 10.0.1 JDK 在 Windows 10 上解决此问题的方法

  1. Downloaded the new gradle version(latest is 4.8.1 at the time of this post) from: https://gradle.org/releases
  2. Followed the following steps mentioned at: https://gradle.org/install/
  1. 从以下位置下载了新的 gradle 版本(在本文发布时最新版本为 4.8.1):https://gradle.org/releases
  2. 遵循以下提到的步骤:https: //gradle.org/install/

(i) Microsoft Windows users

(i) 微软视窗用户

Create a new directory C:\Gradle with File Explorer.

使用文件资源管理器创建一个新目录 C:\Gradle。

Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-4.8.1 to your newly created C:\Gradle folder.

打开第二个文件资源管理器窗口并转到下载 Gradle 发行版的目录。双击 ZIP 存档以显示内容。将内容文件夹 gradle-4.8.1 拖到新创建的 C:\Gradle 文件夹中。

(ii) Added PATH C:\Gradle\gradle-4.8.1\bin to environment variable

(ii) 将 PATH C:\Gradle\gradle-4.8.1\bin 添加到环境变量

  1. After above went to File --> Settings-->Build Tools --> Gradle and did set Gradle home to C:/Gradle/gradle-4.8.1

  2. Then went to View --> Tool Windows --> Gradle and hit the Refresh all Gradle projects icon.

  1. 在上面转到文件 --> 设置 --> 构建工具 --> Gradle 并确实将 Gradle home 设置为 C:/Gradle/gradle-4.8.1

  2. 然后转到 View --> Tool Windows --> Gradle 并点击 Refresh all Gradle projects 图标。

回答by Zosia Czerniawska

I had similar issue with IntelliJ version2018.1.6 x64. I installed Java8 and the problem disappeared.

我在 IntelliJ version2018.1.6 x64 上遇到了类似的问题。我安装了Java8,问题消失了。

回答by S34N

Even if you're using Linux the solution remains the same.

即使您使用的是 Linux,解决方案也保持不变。

Inside the root folder of your Project(Working Directory) >>

在项目的根文件夹内(工作目录)>>

gradle/wrapper/

There's a file named >>

有一个文件名为 >>

gradle-wrapper.properties

Change the distributionUrl line (Outdated Version):

更改 distributionUrl 行(过时版本):

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

To the following distributionUrl (Compatible/Correct Version):

到以下 distributionUrl(兼容/正确版本):

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

Don't forget to configure IntelliJ IDEA Settings to use the Gradle-Wrapper Configurations.

不要忘记配置 IntelliJ IDEA 设置以使用 Gradle-Wrapper 配置。

回答by M. Solomonik

After downloading my latest Gradle version and changing the path environment variable to C:\Gradle\gradle-4.10-bin\gradle-4.10\bin, not what was on the instructions, and changing to "Use local gradle distrubution" under Settings- Build, Execution, Deployment - Gradle It worked for me.

下载我最新的 Gradle 版本并将路径环境变量更改为 C:\Gradle\gradle-4.10-bin\gradle-4.10\bin 后,而不是说明中的内容,并在 Settings-Build 下更改为“Use local gradle distrubution” ,执行,部署 - Gradle 它对我有用。

回答by Alif

Solution summary:

解决方案总结:

  • Turn back to older version of jdk
  • Remove problematic jdk(s) from intelliJ
  • 转回旧版本的jdk
  • 除去有问题的jdk,由(S)intelliJ

A full demonstration is given below for intelliJin ubuntu 18.04.1

下面的完整演示中给出intelliJubuntu 18.04.1

enter image description here

在此处输入图片说明

fig1: Installing openjdk-8.

图 1:安装openjdk-8.

enter image description here

在此处输入图片说明

fig2: Adding jdk8 to Project Structure. Click +button then choose JDK. Now choose JDK home pathto jdk8. Mine was, as you can see from fig3, /usr/lib/jvm/java-1.8.0-openjdk-amd64

图 2:将 jdk8 添加到项目结构。单击+按钮,然后选择JDK。现在选择JDK home pathjdk8。我的是,正如你从图 3 中看到的,/usr/lib/jvm/java-1.8.0-openjdk-amd64

enter image description here

在此处输入图片说明

fig3: openjdk-8 is added to intelliJ. [a:] Time to remove newer versions of jdkfrom intelliJ.

图 3:将 openjdk-8 添加到intelliJ. [a:] 是时候jdkintelliJ.

enter image description herefig4: Select 10(notice that the JDK home pathcontains java-1.11.0-openjdk-amd64) and press -button to remove 10.

在此处输入图片说明图4:选择10(注意JDK home path包含java-1.11.0-openjdk-amd64)并按下-按钮删除10

enter image description herefig5: after removal of jdk-10select jdk-8(named 1.8in fig5) and press ok.

在此处输入图片说明图5:删除后jdk-10选择jdk-8(1.8在fig5中命名)并按ok

enter image description herefig6: Now go to File->Settings->Build, Execution, Deployment->Build tools->Gradle->Gradle JVMand choose the same path that you have set as JDK home pathwhile adding 1.8in Project Structureand press Ok. Click Buildand choose Make new module appand the app module should be created. Now if pressing Runand choosing appmodule gets your app running, you have a good day :) and if not, recheck activities mentioned in fig3[a] & fig6 once.

在此处输入图片说明图6:现在转到File-> Settings-> Build, Execution, Deployment-> Build tools-> Gradle->Gradle JVM并选择您JDK home path在添加1.8时设置的相同路径Project Structure并按Ok。单击Build并选择Make new module app,应创建应用程序模块。现在,如果按下Run并选择app模块使您的应用程序运行,那么您将度过美好的一天 :) 如果没有,请重新检查 fig3[a] 和 fig6 中提到的活动一次。

回答by Mindaugas Bernatavi?ius

Going to:

即将:

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

and selecting:

并选择:

Use local gradle distribution

fixed it for me.

为我修好了。

回答by Hassan Badawi

same in mac == Could not determine Java version using executable /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java. this help me

在 mac 中相同 == 无法使用可执行文件 /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java 确定 Java 版本。这对我有帮助

cd /Library/Java/JavaVirtualMachines

then run

然后运行

sudo rm -rf jdk-11.0.2.jdk

after that try to build

之后尝试构建

it will request SDK select it from Contents

它会要求 SDK 从 Contents 中选择它