Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java FX Media file not available in JAR

jroxOct 26 2012 — edited Oct 27 2012
When 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());
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 24 2012
Added on Oct 26 2012
2 comments
1,390 views