Audio doesnt work after exporting game [SOLVED]


when i run my game in eclipse, everything is fine.

But when i export it as a runnable jar, i am getting openAL exceptions, the background music doesnt play at all and soundeffects sound strange as well.

I use "java -jar -Djava.library.path=.libnatives connections.jar" to start the executable jar.

This is the exception i get when running the game:

08.10.2009 12:09:27 playInNewThr
org.lwjgl.openal.OpenALException: OpenAL error: Invalid Value (40963)
        at org.lwjgl.openal.Util.checkALError(
        at org.lwjgl.openal.AL10.alBufferData(
        at gamestates.MenuState.setupAudio(
        at gamestates.MenuState.<init>(
        at main.Connections.initGame(
        at main.Connections.main(

What botheres me most is that i don't even know what the error is about exactly :(

I hope someone can help me with this problem

see reply #7 and #8

please post this line here:

at gamestates.MenuState.setupAudio(

here it is:

private void setupAudio() {
      // grab a handle to the audio system
      audio = AudioSystem.getSystem();
      // set overall volume
      audio.setMasterGain((float) gameSettings.getVolume() / 100);  // getVolume returns [0 .. 100]

      // setup our ear tracker to track the camera's position and orientation.
      // setup a music track and start playing it
      AudioTrack music1 = getMusic(MenuState.class.getResource("/data/sound/1.wav"));
      audio.getMusicQueue().play();  // <

Line 778

private AudioTrack getMusic(URL resource) {
      // Create streaming, looping, non-relative music clip.
      AudioTrack sound = AudioSystem.getSystem().createAudioTrack(resource, true);
      return sound;

Probably a classpath is missing so getResource doesn't find the wav-file.

and where would i add that classpath?

aside from that, if i dont stream the musictrack, but load it as a whole, i get an OutOfMemory exception, which seems to indicate that it does find the music file

Than you have to increase the heap-size of the virtual machine.

Add this to the VM-arguments: "-Xmx256m" to increase the maximum heap-size to 256 MB.

Hi again

It works now :slight_smile:

I had to set the java heap space to 512mb though. The actual .wav file is only about 73mb in size.

Isnt there a way to reduce the memory amount needed? mp3 doesnt work, right?

I still wonder why streaming doesn't work  :-o I've also tried it with another .wav file, which is only about 1.5mb in size, but i got the same openAL exception that i posted in the opening post.

Anyways, thanks a lot for your help XD

I recommend OGG for audio.

Use Audacity to convert them:

It is also perfect when you want to tweak/edit your sounds.

Thanks for the tip!

after using .ogg, i could even stream the music and i got no more OpenAL exceptions :smiley:

and i dont have to expand the heap space anymore as well.