[英]Could not determine Java version using executable C:\Program Files\Java\jdk-10.0.1\bin\java.exe
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. 当我尝试使用Gradle在IntelliJ IDEA版本2018.1.2中创建新项目时出现此错误。 It said:
它说:
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来解决问题。
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 ). 要解决此问题,请为您的操作系统安装最新的Gradle( 安装指南 )。 For MacOS you can use Homebrew:
对于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. 此命令将下载Gradle 4.8,为当前项目创建脚本gradlew和gradlew.bat。 From this point, you should use these scripts in the command-line.
从这一点开始,您应该在命令行中使用这些脚本。
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'包装'任务配置”
Apply changes, press ok and re-build (re-sync) Gradle and everything should be fine. 应用更改,按确定并重新构建(重新同步)Gradle,一切都应该没问题。 I hope this helps.
我希望这有帮助。
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上解决此问题的方法
(i) Microsoft Windows users (i)Microsoft Windows用户
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. 打开第二个文件资源管理器窗口,然后转到下载Gradle分发版的目录。 Double-click the ZIP archive to expose the content.
双击ZIP存档以显示内容。 Drag the content folder gradle-4.8.1 to your newly created C:\\Gradle folder.
将内容文件夹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添加到环境变量中
After above went to File --> Settings-->Build Tools --> Gradle and did set Gradle home to C:/Gradle/gradle-4.8.1 之后转到文件 - >设置 - >构建工具 - > Gradle并将Gradle home设置为C:/Gradle/gradle-4.8.1
Then went to View --> Tool Windows --> Gradle and hit the Refresh all Gradle projects icon. 然后转到View - > Tool Windows - > Gradle并点击Refresh all Gradle projects图标。
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配置。
Solution summary: 方案摘要:
jdk
(s) from intelliJ
intelliJ
删除有问题的jdk
A full demonstration is given below for intelliJ
in ubuntu 18.04.1
下面
intelliJ
了ubuntu 18.04.1
完整演示
fig1: Installing openjdk-8
. 图1:安装
openjdk-8
。
fig2: Adding jdk8 to Project Structure . 图2:将jdk8添加到项目结构中 。 Click
+
button then choose JDK
. 单击
+
按钮,然后选择JDK
。 Now choose JDK home path
to jdk8. 现在选择jkk8的
JDK home path
。 Mine was, as you can see from fig3, /usr/lib/jvm/java-1.8.0-openjdk-amd64
从图3可以看出,我的是
/usr/lib/jvm/java-1.8.0-openjdk-amd64
fig3: openjdk-8 is added to intelliJ
. fig3:openjdk-8被添加到
intelliJ
。 [a:] Time to remove newer versions of jdk
from intelliJ
. [a:]是时候从
intelliJ
删除更新版本的jdk
了。
fig4: Select
10
(notice that the JDK home path
contains java-1.11.0-openjdk-amd64
) and press -
button to remove 10
. 图4:选择
10
(注意JDK home path
包含java-1.11.0-openjdk-amd64
)并按-
按钮删除10
。
fig5: after removal of
jdk-10
select jdk-8(named 1.8
in fig5) and press ok
. 图5:删除
jdk-10
选择jdk-8(图5中命名为1.8
)并按ok
。
fig6: Now go to
File
-> Settings
-> Build, Execution, Deployment
-> Build tools
-> Gradle
-> Gradle JVM
and choose the same path that you have set as JDK home path
while adding 1.8
in Project Structure
and press Ok
. 图6:现在转到
File
- > Settings
- > Build, Execution, Deployment
- > Build tools
- > Gradle
- > Gradle JVM
并选择与JDK home path
相同的路径,同时在Project Structure
添加1.8
,然后按Ok
。 Click Build
and choose Make new module app
and the app module should be created. 单击
Build
并选择Make new module app
然后创建应用程序模块。 Now if pressing Run
and choosing app
module gets your app running, you have a good day :) and if not, recheck activities mentioned in fig3[a] & fig6 once. 现在,如果按下
Run
并选择app
模块让你的应用程序运行,那么你将度过美好的一天:)如果没有,请重新检查图3 [a]和fig6中提到的活动一次。
Going to: 即将:
File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle
and selecting: 并选择:
Use local gradle distribution
fixed it for me. 为我修好了。
It's most likely your gradle version. 这很可能是你的gradle版本。 Gradle 4.7+ has JDK 10 support.
Gradle 4.7+支持JDK 10。
下载我最新的Gradle版本并将路径环境变量更改为C:\\ Gradle \\ gradle-4.10-bin \\ gradle-4.10 \\ bin,而不是说明中的内容,并在Settings- Build下更改为“Use local gradle distrubution” ,执行,部署 - Gradle它对我有用。
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. 作为最后一步,我必须为我的项目定义新的sdk。 Previously, it was showing 2-3 SDKs.
以前,它显示了2-3个SDK。 after re-installation, there were none.
重新安装后,没有。 i added one.
我加了一个。 To add SDK in Intellij: Go to- File- Project Structure- Project Settings- Project SDK...
在Intellij中添加SDK:转到 - 文件 - 项目结构 - 项目设置 - 项目SDK ...
Added one sdk here to point to the jdk installed path. 在这里添加了一个sdk以指向jdk安装路径。
I had similar issue with IntelliJ version2018.1.6 x64. 我有类似IntelliJ版本2018.1.6 x64的问题。 I installed Java8 and the problem disappeared.
我安装了Java8,问题就消失了。
same in mac == Could not determine Java version using executable /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java. 相同的在mac ==无法使用可执行文件/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/bin/java确定Java版本。 this help me
这对我有帮助
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从内容中选择它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.