Swing Issue on Java 10

隐身守侯 提交于 2019-12-01 11:46:57

Yes, this is due to the module system. You are accessing internal APIs, which the JPMS won't let you do by default.

Quick fix

To quick-fix this, use the command line option --add-exports %module/%package=ALL-UNNAMED for each package mentioned by the messages, e.g.:

--add-exports java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED

(No, there is no wildcard) You have to add these to your build command for Java 9+ and at some point (likely Java 12+) also to your execution command.

Proper fix

As mentioned, this is just a quick-fix. With the module system in place, the JDK team might more aggressively refactor internals like the API you are using, so chances are that you will run into problems with changed or removed classes in the future.

The proper fix is to remove your dependencies on these internals. A first step is to check whether the features you're using there might in the meantime have gotten a standardized API.

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