Question

I am using LWJGL and Slick2d. I have made a project and it runs fine from within eclipse but when I export it as an executable jar file it does nothing. I tried running it from the command prompt and it gives me this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at org.lwjgl.Sys$1.run(Sys.java:73)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
    at org.lwjgl.Sys.loadLibrary(Sys.java:95)
    at org.lwjgl.Sys.<clinit>(Sys.java:112)
    at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
    at net.<My Package>.game.<My Main Class>.start(<My Main Class>.java:26)
    at net.<My Package>.game.<My Main Class>.main(<My Main Class>.java:75)

I've tried every article I have read about exporting it. I did see the Distributing Your LWJGL Application doc but nothing works. I've edited the class-path string in the MANIFEST file, and it doesn't work. One thing that I will note is that when I export it gives me a warning saying:

This operation repacks referenced libraries.
Please review the licenses associated with 
libraries you wish to reference to make sure you 
are able to repack them using this application. 
Note also that this operation does not copy 
signature files from original libraries to the 
generated JAR file.

And I just hit OK.

I hope that I provided enough information to contribute to the solution to the problem. I would be glad to give anymore information.
Note: I removed any personal information in the code block.

Was it helpful?

Solution

There may be one of a few things wrong. Try doing the below, in order.

  • Use the command line argument -Djava.library.path=path_to_"lwjgl.dll"_directory (e.g. -Djava.library.path=C:/programs/myprogram/natives) when running the jar.
  • Change the directory. In command prompt, this can be accomplished by typing cd new_dir_here. More info here.

  • Create a .bat file that contains the command line arguments you used.

  • Use Launch4j. Put . in the Change dir: field, and put lwjgl.jar and lwjgl.dll in the same folder as the generated .exe file. This is how I solved my problem.

OTHER TIPS

It sounds like you don't have the natives packed into your jar. I would use Jarsplice to package them, as well as all your other libraries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top