0

I recently got into LWJGL, and it's working fine in the IDE. But when I export my project to a JAR file, it's not working similarly to in the IDE.

I know how I can include my LWJGL JAR in the game JAR file, but I want the natives in there as well so people don't need to download lots of files to run my game.

How can I do this in IntelliJ?

When I run the JAR file, I get a java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path error. I know I can do -Djava.library-path="<path_to_native>", but I want my program to be easy-to-use for others. The easiest would be to just have one file - the JAR. So is it possible to get the natives inside the JAR? - how?

Soni
  • 77
  • 1
  • 8
  • Are you using LWJGL 2.x or 3? – httpdigest Dec 03 '18 at 18:22
  • If you use LWJGL 3 (the current version) - which I highly recommend - then see https://stackoverflow.com/questions/1082580/how-to-build-jars-from-intellij-properly#answer-4901370 to create a runnable jar from within IntelliJ IDEA. There, use "Create JAR from Modules" and select "extract to the target JAR" under 'JAR files from libraries'. This works in LWJGL 3 because it automatically extracts the natives from the JAR file into a temporary folder and loads them from there. – httpdigest Dec 03 '18 at 18:30
  • @httpdigest I have no idea what version I use... I just followed a tutorial. I downloaded it from [here.](http://www.mediafire.com/file/tjfu506bt9tsp56/Libs.zip) – Soni Dec 03 '18 at 18:54
  • I'd recommend you download it from some official sources, such as https://www.lwjgl.org/download or http://legacy.lwjgl.org/download.php.html . Without any more information I cannot help you. And if you don't even know yourself what you are using, well... – httpdigest Dec 03 '18 at 19:05
  • @httpdigest I can't find out how to add the natives now? I added the lwjgl.jar file and I get a `java.lang.NoClassDefFoundError` – Soni Dec 04 '18 at 17:59

0 Answers0