0

I want to add an AudioClip to my Game. I used Java and JavaFX and wrote my Code in Eclipse. The error that shows up is

java.lang.IllegalAccessError: class com.sun.media.jfxmediaimpl.NativeMediaManager (in unnamed module @0x5e355576) 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 @0x5e355576>

This is the code where i tried to initiliaze my AudioCLip

public AudioClip OWMusic = new AudioClip(getClass().getResource("/OWMusic.mp3").toExternalForm());

niMtAndoX
  • 9
  • 2
  • Consider making your code [modular](https://www.oracle.com/corporate/features/understanding-java-9-modules.html). – Abra Jun 27 '22 at 04:07

1 Answers1

0

In your project, create a resources folder and add the OWMusic.mp3 file inside. If this does not work, ensure the folder is added to your project's classpath. This last step depends more on your build system (ant/maven/gradle) and less the concise IDE you are using.

See also How do I add a resources folder to my Java project in Eclipse

Queeg
  • 7,748
  • 1
  • 16
  • 42