java - 如何修复 "module javafx.graphics does not "在 Java 中打开 com.sun.javafx.text“to unnamed module”的问题?

标签 java javafx java-12

我正在使用

jdk12,javafx12
和eclipse ide。当我运行我的代码时,它应该创建一个 Pane 、一个文本字段和一些按钮。它只是创建了 Pane ,然后我得到了一个错误

我尝试使用

jdk11
我得到了同样的错误

我把这些写给

VM
参数:

--module-path /home/beyza/openjfx-12.0.1_linux-x64_bin-sdk/javafx-sdk- 
12.0.1/lib
--add-modules javafx.controls
--add-modules javafx.base
--add-modules javafx.graphics
--add-modules javafx.fxml
--add-modules javafx.media
--add-exports javafx.graphics/com.sun.javafx.util=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.util=ALL-UNNAMED 
--add-exports javafx.base/com.sun.javafx.logging=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.prism=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.geom.transform=ALL- 
UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.glass.utils=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.font=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED 
--add-exports javafx.controls/com.sun.javafx.scene.control=ALL- 
UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.scene.input=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.prism.paint=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.scenario.effect=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.text=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED 
--add-exports javafx.graphics/com.sun.javafx.scene.text=ALL-UNNAMED
--add-opens javafx.graphics/javafx.scene=ALL-UNNAMED 
--add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED

Here is my main class

我遇到了这个错误


    Exception in thread "JavaFX Application Thread" 
java.lang.ExceptionInInitializerError

    Caused by: java.lang.reflect.InaccessibleObjectException: Unable 
    to make private int 
    com.sun.javafx.text.PrismTextLayout.getLineIndex(float) 
    accessible: module javafx.graphics does not "opens 
    com.sun.javafx.text" to unnamed module

最佳答案

正确的答案是 --add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED 到 VM 选项。

但是如果像这样编写一个简单的启动器类,任何人都可以避免这些 VM 选项:

public class AppLauncher {
    public static void main(String[] args) {
        YourAppMainClassNameHere.main(args);
    }
}

并通过它运行应用。

关于java - 如何修复 "module javafx.graphics does not "在 Java 中打开 com.sun.javafx.text“to unnamed module”的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56900737/

相关文章:

java - jdk12 中 appletviewer 的替代方案

jmeter - Java 12 JMeter 5 HTTP/2 请求 java.lang.NoClassDefFoundError : org/eclipse/jetty/alpn/client/ALPNClientConnectionFactory

java - IntelliJ 编译错误 zip END header 未找到

java - 如何解释 Java 线程转储?

java - 使用 css 自定义 JavaFx Alert

java - 我无法安装 JDK 12 (Java SE12) 没有可供下载的源

java - 线程 "main"java.util.UnknownFormatConversionException : Conversion = 'O' 中出现异常

java - Android Activity 和 Java 类之间的通信

java - TableColumn #setCellValueFactory 对于具有 HashMap 的类

JavaFx 对话框不显示所有内容文本