问题
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:-
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.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.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