Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a game in Java using Slick2d, which depends on LWJGL. I can get everything to work in my development environment, but when I export it to a .jar, it needs the natives placed in the same directory as the .jar. What I'm asking is if it's possible to package the natives for all operating systems in the .jar, and automatically use the right ones depending on what OS was detected.

So, is this possible?

share|improve this question
    
Hey Carter H. Since this question is not strictly related to gamedev but to packaging native libs into Java JARs in general this question would belong better at www.stackoverflow.com where you will probably receive a good answer faster. I've flagged your question to be moved there. –  Roy T. Mar 17 '12 at 22:32
1  
@Roy... as Slick2D and LWJGL are both rather game oriented, I can't help but think that this is indeed more game oriented than not. –  PlayDeezGames Mar 18 '12 at 2:19
add comment

1 Answer

I recently had the same sort of issues.

I recommend the following:

First, get jarsplice.

Also, assuming that your dev environment is Eclipse, but if not, you'll need to do the equivalent.

  1. Export your game to a jar (NOT a runnable jar, just a regular jar)
  2. Start jarsplice. Add your jar.
  3. Add slick.jar, lwjgl.jar, and whatever other jars you are using from slick2d (for example, I use audio, and so usually need the jogg and jorbis jar file)
  4. Add the native-(OS).jar(like native-win32.jar, native-mac.jar, native-linux.jar) files in the slick lib directory. (DO NOT ADD THE NATIVES, THEY ARE IN THE JARS ABOVE)
  5. Set the appropriate main class.
  6. Create the fat jar
  7. Behold as your jar will work on windows, mac, and linux.
share|improve this answer
    
When exporting the project from Eclipse, I have to have the libraries included in the project or else I get compile errors. –  Carter H Mar 18 '12 at 9:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.