IntelliJ Gradle 插件:提供的 javaHome 似乎无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29356796/
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 Plugin: The supplied javaHome seems to be invalid
提问by Eric Francis
Similar to:
- Intellij 14 the supplied javaHome seems to be invalid
- Android Studio - supplied javaHome is not a valid folder
类似于:
- Intellij 14 提供的 javaHome 似乎无效
- Android Studio - 提供的 javaHome 不是有效文件夹
However, I am trying to use my JAVA_HOME
variable which is set to C:\Program Files\Java\jdk1.8.0_40
但是,我正在尝试使用JAVA_HOME
设置为的变量C:\Program Files\Java\jdk1.8.0_40
I do not understand why intellij is looking for the JDK inside of its install directory.
我不明白为什么 intellij 在其安装目录中寻找 JDK。
In intellij:
在智能中:
Executing external task 'bootRun'...
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1\jre\bin\java.exe
External task execution finished 'bootRun'.
C:\>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
C:>env
...
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_40
...
采纳答案by Sergii Pechenizkyi
IDEA comes in 2 versions: 32bit and 64bit.
IDEA 有 2 个版本:32 位和 64 位。
Your JAVA_HOME
is 64bit version of Java so you have to run 64bit version of the IDEA ...\IntelliJ\IntelliJ IDEA Community Edition 14.1.2\bin\idea64.exe
.
您JAVA_HOME
是 64 位版本的 Java,因此您必须运行 64 位版本的 IDEA ...\IntelliJ\IntelliJ IDEA Community Edition 14.1.2\bin\idea64.exe
。
Otherwise, you can provide 32bit JDK or tweak the behaviour with IDEA settings https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under
否则,您可以提供 32 位 JDK 或使用 IDEA 设置调整行为 https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-磨合
回答by mushfek0001
Try manually setting a JDK from File > Project Structure > Project > Project SDK
, Then rebuild.
尝试从 手动设置 JDK File > Project Structure > Project > Project SDK
,然后重建。
回答by 4ndrew
I've solved this issue by putting gradle.properties file in the same dir as build.gradle with exact path to my JDK:
我通过将 gradle.properties 文件放在与 build.gradle 相同的目录中,并使用我的 JDK 的确切路径解决了这个问题:
org.gradle.java.home = C:/Dev/JDK
Actually it is not a correct solution, probably it should be fixed in IDE, I see in IDEA logs something like (when I executing gradle task of already imported project):
实际上这不是一个正确的解决方案,可能它应该在 IDE 中修复,我在 IDEA 日志中看到类似的内容(当我执行已导入项目的 gradle 任务时):
INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Dev/JDK
But when I going to import gradle module to the project I don't see such kind of message, probably IDEA passes link to bundled JRE which is actually not a JDK.
但是当我将 gradle 模块导入到项目中时,我没有看到此类消息,可能 IDEA 将链接传递给了实际上不是 JDK 的捆绑 JRE。
回答by Pradyumna Swain
The problem lies in Intellij IDEA itself. If you go to Intellij installed directory, you will find a jredirectory where it's searching for the above said java.exe. But the problem here is there is no bindirectory here instead another jredirectory available.So, solution is upfront. copy all the contents from inner jredirectory and put it in outer jredirectory.
问题在于 Intellij IDEA 本身。如果您转到 Intellij 安装目录,您将找到一个jre目录,它正在搜索上述java.exe。但是这里的问题是这里没有bin目录,而是另一个可用的jre目录。所以,解决方案是预先的。复制内部jre目录中的所有内容并将其放在外部jre目录中。
回答by Eric Francis
UPDATEI believe this issue has been fixed as of 14.1.3
更新我相信这个问题已在 14.1.3 中得到修复
Related bug links:
相关错误链接:
That said, I was able to get by using @Sergii Pechenizkyi's answer; however, it seems like this problem has a few different solutions.
也就是说,我能够通过使用@Sergii Pechenizkyi 的回答获得;然而,这个问题似乎有几个不同的解决方案。
回答by user39950
This can be fixed by setting the ProjectSDK in Module settings to a JDK (as opposed to the ModuleSDK (which shall be AndroidSDK)
这可以通过将模块设置中的项目SDK 设置为 JDK(而不是模块SDK(应为AndroidSDK)来解决)
回答by humazed
回答by user6718911
Upgrading IntelliJ UE from v14.1.1 to 14.1.7 worked for me.
将 IntelliJ UE 从 v14.1.1 升级到 14.1.7 对我有用。
回答by user7369766
It is not working on the Mac as of 16.3. The SDK was set correctly in Project Settings and the Gradle dialog box no longer allows you to select the JDK. The only solution that worked was creating the gradle.properties file.
从 16.3 开始,它不适用于 Mac。SDK 在 Project Settings 中设置正确,Gradle 对话框不再允许您选择 JDK。唯一有效的解决方案是创建 gradle.properties 文件。
回答by dkochheiser
On OSX 10.12.x, Intellij v16.3, I had to go into:
在 OSX 10.12.x、Intellij v16.3 上,我不得不进入:
- ~/Library/Preferences/IntelliJIdea2016.3
- Create a file called: idea.jdk
- Add the following to it: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk (or whatever JDK you have installed
- ~/Library/Preferences/IntelliJIdea2016.3
- 创建一个名为:idea.jdk 的文件
- 向其中添加以下内容:/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk(或您安装的任何 JDK
This was a fix I've had to do in v16 of Intellij found on jetbrains site. At one point I had to remove it, on the upgrade to 16.3 I had to add it back. https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under
这是我必须在 jetbrains 网站上找到的 Intellij v16 中进行的修复。有一次我不得不删除它,在升级到 16.3 时我不得不将它添加回来。 https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under