导入 java.awt 无法解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51503140/
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
The import java.awt cannot be resolved
提问by Livio
I have installed the Eclipse [Version: Photon Release (4.8.0)] and JDK 10 on a MacBookPro with macOS 10.13.5
When I write in my code: import java.awt.*;
我已经在装有 macOS 10.13.5 的 MacBookPro 上安装了 Eclipse [版本:Photon Release (4.8.0)] 和 JDK 10 当我编写代码时: import java.awt.*;
I get the error:
我收到错误:
The import java.awt cannot be resolved
导入 java.awt 无法解析
Is the java.awt
included in JDK 10 ? If yes where is and how can I make visible to Eclipse? If no how can I add java.awt?
是否java.awt
包含在 JDK 10 中?如果是,我在哪里以及如何使 Eclipse 可见?如果没有,我该如何添加 java.awt?
采纳答案by Naman
Is the
java.awt
included in JDK 10?
是否
java.awt
包含在 JDK 10 中?
Ye, the package does exist. The Java10 API docsdo confirm the same as well.
是的,该包确实存在。Java10 API 文档也证实了这一点。
If yes where is and how can I make visible to Eclipse?
如果是,我在哪里以及如何使 Eclipse 可见?
In a modular code, all you need to do, is to resolve the java.desktop
moduleby declaring a dependency on it in your module-descriptor file(module-info.java
). i.e.
在模块化代码中,您需要做的就是通过在模块描述符文件()中声明对java.desktop
模块的依赖来解析模块module-info.java
。IE
requires java.desktop;