导入java.awt无法解析 [英] The import java.awt cannot be resolved
问题描述
我在MacBookPro上安装了Eclipse [Version:Photon Release(4.8.0)]和JDK 10,使用macOS 10.13.5
当我在我的代码中写入时: import java。 awt。*;
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.*;
我收到错误:
导入java.awt无法解析
The import java.awt cannot be resolved
是 java.awt
包含在JDK 10中?如果是,那里是什么以及如何让Eclipse可见?如果没有,我怎么能添加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中?
Is the
java.awt
included in JDK 10?
是的,包确实存在。 Java10 API文档确认了同样如此。
Ye, the package does exist. The Java10 API docs do confirm the same as well.
如果是,那里是什么以及如何让Eclipse可见?
If yes where is and how can I make visible to Eclipse?
在模块化代码中,您需要做的就是通过在模块描述符文件中声明对它的依赖来解析 java.desktop
模块( module-info.java
)。即。
In a modular code, all you need to do, is to resolve the java.desktop
module by declaring a dependency on it in your module-descriptor file(module-info.java
). i.e.
requires java.desktop;
这篇关于导入java.awt无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!