简体   繁体   English

IntelliJ - java:找不到JDK'1.8'

[英]IntelliJ - java: Cannot find JDK '1.8'

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. 我正在使用IntelliJ IDEA 14.0.3。 I have selected the 'Java Hello World' sample. 我选择了“Java Hello World”样本。 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 module but still can't this to work. Any help would be greatly appreciated. 当我尝试运行程序时,我收到错误:“错误:java:找不到JDK'1.8 '模块'Deliverable4'。我已经尝试过这篇文章中的每一个建议intellij - java:找不到JDK'1.7'模块但仍然不能这样做。任何帮助将不胜感激。

Go to: 去:

File => Project structure File =>项目结构

And check: Project , Modules and SDKs tabs: 并检查: ProjectModulesSDKs标签:

在此输入图像描述

If at SDKs Java 1.8 Sdk isn't selected just add it. 如果没有选择SDKs Java 1.8 Sdk,只需添加它。

And press OK . 然后按OK

从IntelliJ版本14.0.3更新到14.1似乎解决了这个问题。

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 home path是红色的,所以我点击了路径右边的文件夹图标。

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. 即使弹出的Finder窗口已经将我放在正确的目录/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home (也许它在我最新更新的类路径所说的Java所在的地方放弃了我?),以红色显示的路径与该路径不同。 Instead, it was using the old one, something like /Library/Java/JavaVirtualMachines/jdk-1.8_(???)/Contents/Home . 相反,它使用旧的,类似/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. 单击确定,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 sro macOS 10.12.6

If the update solution given above doesn't work for somebody, consider not using the bin directory like the one used in the PATH environment but rather the java root directory . 如果上面给出的更新解决方案对某人不起作用,请考虑不使用像PATH环境中使用的bin目录,而是使用java根目录 In short instead of: 总之而不是:

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. 一切都会好起来的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM