Error while loading a sound URL

I have just started to play a little with jME and I come up on a problem.



In the turorial HelloIntersection on the wiki page you learn how to load sounds into you game. However every time I tried to put an own sound for example just a regular song( in wav format)…it can't load the file and I recieve a nullpointerexception.



The line:



laserSound = SoundSystem.create3DSample(getClass().getResource("/jmetest/data/sound/gunshot.wav"));



gererates the error:



INFO: Load file:null

java.lang.NullPointerException

at com.jmex.sound.openAL.objects.util.SampleLoader.loadBuffer(SampleLoader.java:79)

at com.jmex.sound.openAL.objects.Sample3D.<init>(Sample3D.java:78)

at com.jmex.sound.openAL.objects.Sample3D.<init>(Sample3D.java:92)

at com.jmex.sound.openAL.SoundSystem.create3DSample(SoundSystem.java:264)

at Shotter.Shooter.setupSound(Shooter.java:130)

at Shotter.Shooter.simpleInitGame(Shooter.java:77)

at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:497)

at com.jme.app.BaseGame.start(BaseGame.java:56)

at Shotter.Shooter.main(Shooter.java:73)



can anyone help me???


Soollee,



try it:



laserSound = SoundSystem.create3DSample(getClass().getClassLoader().getResource("jmetest/data/sound/gunshot.wav"));




I hope to help you

I've tried your code snippet but unfortunatly it didn't work I still receive the same nullpointer exception.



It's like the loader don't find the file at all even if it there.  :frowning:



Anyone how experienced this before?


did you set Classpath for your project ?

it seems a classpath problem.



Well it works just fine with the original sound files(like laser.ogg and explosion.wav)

However when like I said tried another sound file that from the begining wasn't placed in that directory the program just crasches with that nullpointer exception. Very annoying actually :x

it's not that you have just set classpath to jmetest-data.jar and not rebuilt that jar?

I don't understand…I've run the antbuild and rebuilt my jar files but still it won't work…hmm??

first, do you have the classpath setup against the jmetest-data jar or the jmetest folder directly? secondly, it jmetest-data have you built with and dist-test?

I think i have it against the jmetest folder…and yes i've built the jmetest-data

sorry if my posts sounds like i'm treating both you and myself like an idiot s…it's just that it's impossible to find out what's wrong without knowing everything about it :wink:

if you have it against a folder, make sure the data is really where you think it is…default when doing like that in intellij is, as it should, trying to load from where the classes are built and not from the src folder. for example classes/jmetest/data/sound…and intellij automatically doesnt copy over certain filetypes to that directory…



if you are running against a jre remember that it makes a difference between upper and lower case…

Ok…her's the deal. I've downloaded a gunshot…gun.wav and I have both dried to manually put it in the jmetest/data/sound directory and just import it ( I use Eclipse by the way)…but it still doesn't work and yet i have rebuilt the jar files ans so on  :?..ffs

hard to tell what you are doing wrong then…i still bet it's the placement of the files or the classpath

ok…i've had it…you don't know any guides on how to setup the sound for jME

, or how to setup the classpath in a correct way in eclipse…clearly i'm to stupid to manage by my own…sadly  :smiley:

Personally, I create a JME project in eclipse and run everything from there. All it need contain is the source ( taken from the nightly build ) and a refernce to the sound and LWGJL jars ( see tips on setting up eclipse ).



Your ultimate test is to overwrite one of the demo sound samples with your own to test if the classpath is finding a jar'd version.




Puh!..got it working now…thanks for all your helt guys  :smiley:

so, what was wrong? (helps other to overcome similar problems)

I didn't understand exactly how the jar files works… so yes the problem was that i haven't build the jars correctly and updated the workspace…stupid  :smiley: