4

I have made a Java game using LWJGL, which requires some native files. It all works fine in Eclipse. I want to include the .dll files inside a JAR file, but everytime I try, LWJGL can't find the natives. I have already tried using jarsplice or fatjar, but to no avail. I know minecraft is also programmed using LWJGL, and it somehow manages to load the natives from another folder.

Is there a way to package native files into a JAR file and let a 3rd party library, like LWJGL access them? If not, how would I approach loading them from an external folder?

EDIT: Somehow it worked with the natives in the same directory as the JAR file. I would still like some explanation and perhaps some other methods, though.

Oskar
  • 1,321
  • 9
  • 19

1 Answers1

2

I just ran into this a few weeks ago. Alas, I do not have links, but I found that you cannot reference native files stored inside of a jar file. You have to either programatically extract them before you reference them, or you have to install them alongside your jar file.

I went with the second option and just have Eclipse pack the whole collection into a zip file for distribution.

For the first option, one place to look would be the source code for JNA. They ship dll's/binaries inside their jar file and extract then on demand.

Dave
  • 4,546
  • 2
  • 38
  • 59