This is probably a dumb question, but it's been bugging me for a while.

I can successfully deploy a LWJGL game by adding its natives to my native library path when I run the jar using the -Djava.library.path argument. That works great.

I can also successfully deploy a libGDX game just be exporting a runnable jar. That also works great. My question is... why does that work? Why *don't* I have to set the native library path when I run the libGDX jar? LibGDX is built on top of LWJGL, so shouldn't it require the same native libraries? Does libGDX extract them automagically?

Again, I know how to get both LWJGL and libGDX working, my only question is why I don't seem to have to set the native library path with libGDX, even though LWJGL requires it. I suspect some witchcraft going on, and I'm just curious what that witchcraft is.

(Or maybe my assumptions are invalid and my runnable jar approach has only worked coincidentally and isn't what I should actually be doing?)

Sorry, but that isn't my question. I understand how to load native libraries. I do that with LWJGL, and in fact wrote a tool that handles it for Processing.

My question is, why *don't* I have to do that with libGDX? Every libGDX game I've made works fine as a runnable jar without setting the native library location. Again, I'm not asking how to set the native library location. I'm asking why I *don't seem to have to* with libGDX.

Am I just getting lucky and not hitting any native code (seems unlikely since I'm using OpenGL), or does libGDX have some kind of internal mechanism for extracting its own native libraries?

As you guessed yourself, the libGDX backend jars contain the natives. On startup the framework checks if there is already a folder containing the natives where it expect it to be, if not the folder is created and the natives are extracted from the right backend jar. After that the system properties of lwjgl and other native libs are set and your game starts.

or does libGDX have some kind of internal mechanism for extracting its own native libraries?

Probably, our posts were about how.Anything else?

I meant no disrespect, but I understand how it would work. The tool I wrote for Processing does exactly that (well, similar to that anyway), so I wasn't asking about how it might be done. I couldn't find any easily digestible (I suppose I could traipse through the source) information on it though, so I figured I'd ask here.

Again, I meant no disrespect and I didn't mean to sound dismissive of your answers. I was just looking for specifics on *whether* libGDX in fact did some automagic preprocessing, not *how* it might be done. Mostly I was making sure I was deploying libGDX correctly and not missing a step.

As you guessed yourself, the libGDX backend jars contain the natives. On startup the framework checks if there is already a folder containing the natives where it expect it to be, if not the folder is created and the natives are extracted from the right backend jar. After that the system properties of lwjgl and other native libs are set and your game starts.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org