The import java.awt cannot be resolved

白昼怎懂夜的黑 提交于 2019-12-01 07:38:05

问题


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.*;

I get the error:

The import java.awt cannot be resolved

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?


回答1:


Is the java.awt included in JDK 10?

Ye, the package does exist. The Java10 API docs do confirm the same as well.

If yes where is and how can I make visible to Eclipse?

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;


来源:https://stackoverflow.com/questions/51503140/the-import-java-awt-cannot-be-resolved

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!