Can't start .jar file (using LWJGL)

后端 未结 2 491
无人共我
无人共我 2020-12-21 07:18

Good day!

I created jar file (using Netbeans) and i can\'t start it. This project uses lwjgl libraries. Inside my IDE it works well.

I use next command:

相关标签:
2条回答
  • 2020-12-21 07:22

    From the LWJGL wiki:

    LWJGL consists of two parts, a java part and a native code part. You must setup both of these parts properly in order for lwjgl to work. In order to setup the java part you must add lwjgl.jar to the classpath (as an external library jar). As for the native part (*.dll files on windows, *.so on linux, *.jnilib on mac, etc) you must tell java which folder the natives are located in for LWJGL to be able to find them (use the -Djava.library.path=path/to/dir vm parameter to do this).

    It seems that you're missing the second part - having the native library on your java.library.path.

    0 讨论(0)
  • 2020-12-21 07:32

    It's not going to work the way you're trying to currently do it, since you need to have the native files along side the jar and point to them via the '-Djava.library.path' parameter.

    If you just want a single jar and want to avoid the hassle of the command line and native files use the JarSplice tool. JarSplice is easy to use and will automatically handle the native file stuff for you.

    1) Simply export your project (class and resources) to a jar (easier just to do it through your IDE).

    2) Then run JarSplice, add all the jars you need to the jars tab (your app jar, lwjgl.jar, and any other external jar you're using).

    3)Then on the natives tab add all the natives files (windows *.dll, linux *.so, mac *.dylib & *.jnilib).

    4)On the class tab add your main class. Then create your jar.

    You can then run this jar just by double clicking it (or if you wish via command line using 'java -jar yourapp.jar').

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