Java FX Media file not available in JAR
jroxOct 26 2012 — edited Oct 27 2012When I package my Swing/Java FX application with Maven (one-jar-plugin) everything seems to work but the Media files I want to use with Java FX.
I'm using the following code to access the files as part the deployed JAR file. When I check the one-jar file I can see the sound.mp3 file being at the correct position but Java is throwing the following error:
MediaException: MEDIA_UNAVAILABLE JAR Entry main/......sound.mp3 not found.
Am I doing something wrong here with accessing the file via the url?
The code works fine in eclipse but does no longer work when deployed as one-jar.
My code:
final URL sound = this.getClass().getResource("/com/mypackage/sound.mp3");
AudioClip soundEffect = new AudioClip(sound.toString());