Problem with webstart

Hello,

will trying to get my little game startable from my homepage, I received this error:

java.lang.NullPointerException
at com.sun.media.sound.WaveFileReader.getAudioInputStream(Unknown Source)
at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
at com.dnsalias.java.gage.sound.WaveEngine.load(WaveEngine.java:56)
at Game.(Game.java:88)
at Game.main(Game.java:56)

The corresponding code looks like this




    createSmoke = new Timer(250,this);
    
    chopper   = getClass().getClassLoader().getResource("./sound/copter.wav");
    explosion = getClass().getClassLoader().getResource("./sound/boom.wav");
    
    try {
           nchopper   = WaveEngine.load(chopper);     <-----  LINE88
           nexplosion = WaveEngine.load(explosion);            
    } catch (LineUnavailableException e) {
    } catch (IOException e) {
    } catch (UnsupportedAudioFileException e) {}

    


I can’t see any error. Getting the file with getResource(…) should be the right way (AFAIK).
The wav-file is placed at the right location within my jar.

What’s wrong here?

Ralf

It might be the “./” in the front, I’m not sure classpaths like them. Also, the preferred way of accessing resources now is:


Thread.currentThread().getContextClassLoader().getResource("blah");

At least thats what I’ve been told :slight_smile:

Kev

Yes it works. Thank you.

Ralf