IntelliJ - java:找不到 JDK '1.8'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29286714/
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 - java: Cannot find JDK '1.8'
提问by Justin Papez
Update: Not sure why this is marked as a duplicate. I had already linked to the other post stating that none of the suggestions / answers work for me. In addition, their question seems to be related to an issue using Windows VMs via Mac, which is irrelevant for me.
更新:不知道为什么这被标记为重复。我已经链接到另一篇文章,指出没有任何建议/答案对我有用。此外,他们的问题似乎与通过 Mac 使用 Windows VM 的问题有关,这与我无关。
I am using IntelliJ IDEA 14.0.3. I have selected the 'Java Hello World' sample. When I try and run the program I receive the error: "Error: java: Cannot find JDK '1.8' for module 'Deliverable4'. I have tried every single suggestion from this post intellij - java: Cannot find JDK '1.7' for modulebut still can't this to work. Any help would be greatly appreciated.
我正在使用 IntelliJ IDEA 14.0.3。我选择了“Java Hello World”示例。当我尝试运行该程序时,我收到错误消息:“错误:java:无法找到模块 'Deliverable4' 的 JDK '1.8'。我已经尝试了这篇文章中的每一个建议intellij - java:找不到模块的 JDK '1.7'但仍然无法正常工作。任何帮助将不胜感激。
采纳答案by Justin Papez
Updating from IntelliJ version 14.0.3 to 14.1 seemed to fix the problem.
从 IntelliJ 版本 14.0.3 更新到 14.1 似乎解决了这个问题。
回答by nazar_art
Go to:
去:
File => Project structure
文件 => 项目结构
And check: Project
, Modules
and SDKs
tabs:
并检查:Project
,Modules
和SDKs
标签:
If at SDKs
Java 1.8 Sdk isn't selected just add it.
如果SDKs
未选择 Java 1.8 Sdk,只需添加它。
And press OK
.
并按OK
。
回答by Tenflex
If the update solution given above doesn't work for somebody, consider not using the bindirectory like the one used in the PATH environmentbut rather the java root directory. In short instead of:
如果上面给出的更新解决方案对某些人不起作用,请考虑不要使用PATH 环境中使用的bin目录,而是使用java root directory。简而言之,而不是:
path_to_java_folder\java\bin\
path_to_java_folder\java\bin\
use:
用:
path_to_java_folder\java\
path_to_java_folder\java\
and everything will work just fine.
一切都会好起来的。
回答by mz496
I suddenly started seeing this issue when upgrading my Java SDK from 1.8 to 10.
将我的 Java SDK 从 1.8 升级到 10 时,我突然开始看到这个问题。
I went to File > Project Structure > SDKs
, JDK home path was in red so I clicked the folder icon to the right of the path.
我去了File > Project Structure > SDKs
,JDK 主路径是红色的,所以我单击了路径右侧的文件夹图标。
Even though the Finder window that popped up already had me in the correct directory /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
(maybe it dropped me wherever my newly updated classpath said Java was?), the path that was displayed in red wasn't the same as that path. Instead, it was using the old one, something like /Library/Java/JavaVirtualMachines/jdk-1.8_(???)/Contents/Home
. Clicked OK and the JDK home path was updated to the correct directory, clicked Apply/OK and everything was fine after that.
即使弹出的 Finder 窗口已经将我放在正确的目录中/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
(也许它把我放在我新更新的类路径说 Java 所在的任何地方?),显示为红色的路径与该路径不同。相反,它使用的是旧的,比如/Library/Java/JavaVirtualMachines/jdk-1.8_(???)/Contents/Home
. 单击确定,JDK 主路径更新到正确的目录,单击应用/确定,之后一切正常。
For reference,
以供参考,
IntelliJ IDEA 2018.2.1 (Community Edition)
Build #IC-182.3911.36, built on August 6, 2018
JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.12.6
IntelliJ IDEA 2018.2.1 (Community Edition)
Build #IC-182.3911.36, built on August 6, 2018
JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.12.6