Cannot access JavaFX class “WebPage” in IntelliJ-IDEA

廉价感情. 提交于 2020-01-14 04:53:07

问题


I've been using JavaFX-11 for a while. I set JavaFX as a Global library in my Project structure. I also added all the modules inside as required in the module-info.class file of my project.

This is working fine, but now I need a Class, "WebPage", that's inside the javafx.web module.

Specifically, it's inside javafx.web.com.sun.webkit.WebPage.

However, my IDE, Intellij-IDEA doesn't access it. When I type the whole path the tooltip says that, Package 'com.sun.webkit' is declared in javafx.web, which does not export it to the module projectname.

I'm not so familiar with how module files work, but I noticed there is also a module info file inside javafx.web. However, it's read-only. How can I access this content?


回答1:


but i noticed there is a module info file inside javafx.web also. But its read only. how can i acces this content?

Few points to gather:-

  1. The class you are looking for must be a module-info.class from the library you've imported and hence it would be a read-only file.

  2. The com.sun.* classes are deprecated and shouldn't be used by end users, hence they've been removed or made JDK internal APIs(not exported) since Java-9.

  3. Try migrating your code relying on such classes. In the meanwhile a temporary solution to still make this work would be to use a VM argument

    --add-exports javafx.web/com.sun.webkit=projectname
    

    where the last argument is your module name as declared in the module-info.java of your project.



来源:https://stackoverflow.com/questions/53999389/cannot-access-javafx-class-webpage-in-intellij-idea

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