java 无法启动编译器:IntelliJ 中未指定 SDK

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

Cannot Start Compiler: The SDK is not specified in IntelliJ

javaintellij-ideajava-8intellij-15

提问by Mona Jalal

I get the error when clicking on the run button that says cannot compiler and I set it to JDK 1.8 in the SDK part but still get the same error in IntelliJ Ultimate. Any thought how this can be fixed?

单击显示无法编译的运行按钮时出现错误,我在 SDK 部分将其设置为 JDK 1.8,但在 IntelliJ Ultimate 中仍然出现相同的错误。有什么想法可以解决这个问题吗?

enter image description here

enter image description here

enter image description here

enter image description here

回答by sisyphus

You need to check also the Projecttab on that page, and each module's SDK under the Modulestab and its Dependenciessub-tab. They all allow you to specify what SDK to use at different levels. The Projecttab should be set to the only SDK you have, but it might not have anything set and similarly for the module dependencies - they should be set to 'use Project SDK' but they might not be. That's usually the source of the kind of error you're seeing.

您还需要检查Project该页面上的选项卡,以及该Modules选项卡及其Dependencies子选项卡下的每个模块的 SDK 。它们都允许您指定在不同级别使用什么 SDK。该Project选项卡应设置为您拥有的唯一 SDK,但它可能没有设置任何内容,对于模块依赖项也类似 - 它们应该设置为“使用项目 SDK”,但也可能不是。这通常是您所看到的那种错误的根源。

回答by P V

Do check if the sdk path is set under platform settings-->SDKs. Some times the sdk is not set there.

请检查是否在平台设置--> SDKs 下设置了 sdk 路径。有时 sdk 没有设置在那里。