[英]Cannot access JavaFX class "WebPage" in IntelliJ-IDEA
I've been using JavaFX-11 for a while.我已经使用 JavaFX-11 有一段时间了。 I set JavaFX as a Global library in my Project structure.
我在项目结构中将 JavaFX 设置为全局库。 I also added all the modules inside as required in the module-info.class file of my project.
我还根据需要在我的项目的 module-info.class 文件中添加了所有模块。
This is working fine, but now I need a Class, "WebPage", that's inside the javafx.web module.这工作正常,但现在我需要一个类“WebPage”,它位于 javafx.web 模块中。
Specifically, it's inside javafx.web.com.sun.webkit.WebPage.具体来说,它位于 javafx.web.com.sun.webkit.WebPage 内。
However, my IDE, Intellij-IDEA doesn't access it.但是,我的 IDE Intellij-IDEA 无法访问它。 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.
当我输入整个路径时,工具提示说,包 'com.sun.webkit' 在 javafx.web 中声明,它不会将它导出到模块项目名称。
I'm not so familiar with how module files work, but I noticed there is also a module info file inside javafx.web.我对模块文件的工作方式不太熟悉,但我注意到 javafx.web 中还有一个模块信息文件。 However, it's read-only.
但是,它是只读的。 How can I access this content?
如何访问此内容?
but i noticed there is a module info file inside javafx.web also.
但我注意到 javafx.web 中也有一个模块信息文件。 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.您要查找的类必须是您导入的库中的
module-info.class
,因此它将是一个只读文件。
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. com.sun.*
类已弃用,不应由最终用户使用,因此自 Java-9 以来,它们已被删除或成为 JDK 内部 API(未导出)。
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
与此同时,仍然使这项工作的临时解决方案是使用 VM 参数
--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.其中最后一个参数是您在项目的
module-info.java
中声明的模块名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.