Search code examples
javaaudioappletjava-web-start

Java Web Start sound


I'm modifying an applet to use Java Web Start, using the applet-desc option to launch the essentially-unmodified code. Everything works great except the sound. This applet uses only the simplest applet sound interface, based on getAudioClip.

Other jar-based resources (i.e. images) work fine in both cases, and audio clips that are not in jars but accessed through real URLs are also fine in both cases.

getResource is returning an in-Jar URL, and when run as a normal applet everything is perfect, but in the same jars, run as a JWS applet the clips are silent.


Solution

  • It turned out the problem was confusion over resource URLs.

    Real applets can get their sounds from JARs using a general URL that has getCodeBase() as a prefix, but JWS applets require you to use getClass().GetResource(..) to construct an explicitly in-resource url.