Search code examples
javalwjgl

Java adding natives to classpath


I have a pretty big game which uses A LOT of libs and I added them in the classpath, which works fine. But when I launch the program it says

no lwjgl in java.library.path

This is easy to solve in Intellji idea but how can I add this in the classpath so that lwjgl knows where the natives are located?


Solution

  • Launch you jar using a batch file:

    java -jar Game.jar -Djava.library.path="path_to_your_natives"
    

    Before creating your Display, you have to call the following line:

    System.load("name_of_dll");
    

    Note, that you don't have to put .dll at the end. You can alternatively call

    System.loadLibrary("path_to_dll");
    

    . That way, you don't have to use a batch file. But you may not forget the extension.