-
May 10th, 2013, 08:13 AM
#1
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:
Code:
WaveData waveFile = WaveData.create(Collisions.class.getResource(sentSound));
AL10.alBufferData(buffer.get(0), waveFile.format, waveFile.data, waveFile.samplerate);
waveFile.dispose();
In my game class I have an instance of the sound class called snd, and when I play a sound I run the command:
Code:
snd.execute(sound);
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, 12:01 PM
#2
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.
Code:
dlls.add("dlls/jinput-dx8_64.dll");
dlls.add("dlls/jinput-raw_64.dll");
dlls.add("dlls/lwjgl64.dll");
dlls.add("dlls/OpenAL64.dll");
for (int i=0; i<dlls.size(); i++)
{
loadJarDll(dlls.get(i));
}
loadJarDll code:
Code:
void loadJarDll(String name)
{
try
{
InputStream in = Collisions.class.getResourceAsStream(name);
File fileOut = new File(System.getProperty("java.io.tmpdir") + name);
System.out.print(System.getProperty("java.io.tmpdir")+name);
OutputStream out = FileUtils.openOutputStream(fileOut);
IOUtils.copy(in, out);
in.close();
out.close();
System.load(fileOut.toString());
}
catch (Exception e)
{
System.out.print("failed");
}
}
Any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|