When I run the .jar, I get a “No lwjgl in java.library.path” error

后端 未结 7 1373
傲寒
傲寒 2020-11-28 15:40

I\'m making a basic game in Java using the LWJGL Library via Netbeans.

I\'ve created a library with the lwjgl, lwjgl_util, and jinput .jar\'s, and I added -Djava.lib

相关标签:
7条回答
  • 2020-11-28 15:42

    you have to point the jvm to where the native files are located using a command line parameter -Djava.library.path="path/to/natives". You could use a batch (.bat) file to specify this and start your application for you.

    Alternatively you can use a tool like JarSplice to create a single executable jar file from all your jars and at the same time include your native files inside it. It automates the tricky part of specifying the natives manually and provides a nicer end user experience.

    To use JarSplice just select your game.jar, lwjgl.jar, lwjgl_util.jar, and jinput.jar in the jars tab. Then all the *.dll, *.so, *.dylib and *.jnilib files in the natives tab. Add your main class on the class tab and create the single executable jar.

    0 讨论(0)
  • 2020-11-28 15:42

    I also got the same error and then realised that I named the file "my_lib.zip" instead of "my_lib.jar". Maybe it may help someone.

    0 讨论(0)
  • 2020-11-28 15:45

    I had this problem and fixed it using jarSplice (http://ninjacave.com/jarsplice)

    make sure you delete all of the preplaced natives in your jar before you create the fat jar, otherwise it will create a duplicate error

    0 讨论(0)
  • 2020-11-28 15:50

    When I had this issue, it was because i accidentally put the argument to specify the location of the natives (-Djava.library.path=/native/) in the field called 'Arguments' under the run category of the options panel, instead of 'vm Options'. As seen here: http://s30.postimg.org/6f90akidt/Capture.png

    0 讨论(0)
  • 2020-11-28 15:51

    And yet another way to do this is with Java Web Start (jnlp): http://lwjgl.org/forum/index.php?topic=3763.0

    This makes sharing your project easier in some ways.

    0 讨论(0)
  • 2020-11-28 15:57

    LWJGL needs the native components for your particular platform to be in java.library.path. These are in the subdirectory native in the LWJGL distribution and end in .so on Linux, OSX and Solaris and .dll for windows.

    0 讨论(0)
提交回复
热议问题