May 10th, 2013, 09:13 AM
OpenAL error with Java Executable Jar File
I am programming a game in Eclipse using OpenAL for sound, and when I play it within the IDE it runs smoothly.
As soon as I export it as an executable jar file and try to run it from the system, the game locks as soon as a sound is about to be played.
This is how I load the file in my Sound Class which uses OpenAL:
In my game class I have an instance of the sound class called snd, and when I play a sound I run the command:
WaveData waveFile = WaveData.create(Collisions.class.getResource(sentSound));
AL10.alBufferData(buffer.get(0), waveFile.format, waveFile.data, waveFile.samplerate);
The rest of the code that follows and precedes these statements is pretty much the exact code from the OpenAL tutorial on lwjgl. And as I said, this works perfectly within Eclipse.
I am quite new with java and getting as far as I have with this has been a nightmare. Does anyone know what the problem could be here? Is there something I am forgetting to tell Eclipse when creating the .jar file? I have told it to package all external jars within the executable.
May 10th, 2013, 01:01 PM
Re: OpenAL error with Java Executable Jar File
Update with now problem: I have recently found out I need to extract the required lwjgl dll files to be opened by the jar externally. I have implemented my code to do this and again, things run smoothly in eclipse, but now when I try to run the executable it won't even OPEN much less freeze when a sound plays.
The dlls are extracted to a temp folder, and then loaded using System.load(dll) with no errors/exceptions.
for (int i=0; i<dlls.size(); i++)
void loadJarDll(String name)
InputStream in = Collisions.class.getResourceAsStream(name);
File fileOut = new File(System.getProperty("java.io.tmpdir") + name);
OutputStream out = FileUtils.openOutputStream(fileOut);
catch (Exception e)
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!