JavaFX Application Constructor Exception: Unable to Construct Application Instance
This error is caused by access restrictions between modules. In Java 9 and later, the modularity system was introduced, and access between modules requires explicit export and import declarations.
According to the error message, the module 'com.example.maven' doesn't export 'com.javaday01' to the module 'javafx.graphics,' but the Application constructor needs to access the 'com.javaday01.javafx01' class.
To solve this, you can add an export statement in the 'module-info.java' file of the 'com.example.maven' module to export 'com.javaday01' to the 'javafx.graphics' module. For example:
module com.example.maven {
exports com.javaday01;
}
Additionally, ensure that the Java version you're using in your development environment aligns with your project requirements. If you're using Java 9 or later, you need to follow the rules of the modularity system. If you're using Java 8 or earlier, you don't need to use the modularity system, and you can add the JavaFX library to your classpath.
原文地址: https://www.cveoy.top/t/topic/pRhs 著作权归作者所有。请勿转载和采集!