Media: Play WAV file inside JAR
java, javafx-2
Solution
try this one out
new Media(MyApplicationClass.class.getResource("/resources/test.wav").toURI().toString())
Media accepts jar uris so it should work fine
Problem
There is only one constructor of the `Media`-class: `public Media(java.lang.String source)` see http://docs.oracle.com/javafx/2/api/javafx/scene/media/Media.html#Media%28java.lang.String%29 This constructor gets a URI as string. I have a JavaFX project and put a WAV file inside this project. When I deploy the project as a JAR, I can see (with 7-Zip for example), that the WAV file is also exported. There is no problem to get the content with ``` MyApplicationClass.class.getResourceAsStream("/resources/test.wav"). ``` But what is the correct URI to refer this WAV file inside the deployed JAR for the `Media` constructor? The URI ``` new Media("jar:.!/resources/test.wav") ``` doesnt work. The URI `"jar:resources/test.wav"` fails too (becouse there is no reference to the JAR file). Does anybody have an idea about the correct URI?