JavaFX Media Application Module Error
Question:
When running a JavaFX 11 application, an error occurs due to a module conflict:
java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module @0x4d7be377) cannot access class com.sun.glass.utils.NativeLibLoader (in module javafx.graphics) because module javafx.graphics does not export com.sun.glass.utils to unnamed module @0x4d7be377
Answer:
The error suggests that the JavaFX media module is not being resolved properly as a module, resulting in the conflict. To resolve this, ensure that the javafx.media module is included in the module path.
Three Ways to Resolve the Module Conflict:
1. Include javafx.media in --add-modules:
/usr/lib/jvm/java-11-openjdk-amd64/bin/java \ -p ~/.m2/repository/org/openjfx/javafx-swing/11/javafx-swing-11.jar: \ ... \ -classpath ~/development/intellij/OpenPatrician/OpenPatricianStandalone/target/classes: \ ... \ --add-modules javafx.controls,javafx.media
2. Make your code modular and add requires javafx.media; to your module descriptor.
3. Use a JDK that includes JavaFX (e.g., BellSoft Liberica or Azul Zulu).
Additional Notes:
The above is the detailed content of How to Resolve JavaFX Media Module Conflicts and IllegalAccessError?. For more information, please follow other related articles on the PHP Chinese website!