Home >Java >javaTutorial >Why am I Getting a Module Error When Running My JavaFX Media Application?

Why am I Getting a Module Error When Running My JavaFX Media Application?

Linda Hamilton
Linda HamiltonOriginal
2024-12-11 18:39:14775browse

Why am I Getting a Module Error When Running My JavaFX Media Application?

Module error when running JavaFx media application

Question:

When I try to run my JavaFX application, I get the following error:

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

I'm not sure what is causing this error. My code is as follows:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.media.AudioClip;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        AudioClip audioClip = new AudioClip(getClass().getResource("/audio/sound.mp3").toString());
        audioClip.play();

The above is the detailed content of Why am I Getting a Module Error When Running My JavaFX Media Application?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn