Hello Guest

Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

  • 4 Replies
  • 17900 Views
I know what this exception is, but why does it only do this when I export the project as a jar and run it? The native libraries are set, it runs perfectly fine in Eclipse so why does this exception occur when I run it as a jar?


Here is the full exception:

Code: [Select]

F:\workspace\Spanish>java -jar Launch.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:56)
Caused by: 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:72)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:65)
        at org.lwjgl.Sys.loadLibrary(Sys.java:81)
        at org.lwjgl.Sys.<clinit>(Sys.java:98)
        at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
        at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)

        at com.adrian.spanish.SpanishGameMain.main(SpanishGameMain.java:39)
        ... 5 more

F:\workspace\Spanish>pause
Press any key to continue . . .

*

Offline Endolf

  • ***
  • 101
    • http://www.computerbooth.com/
When running from the command line you'll need to add -Djava.library.path

e.g. java -jar Launch.jar -Djava.library.path=.

Or something close to that :)

Endolf

is there no option to include the natives into the jar so that i have one jar which runs under win/linux/mac and the user has not to set any paths?

*

Offline kappa

  • *****
  • 1319
is there no option to include the natives into the jar so that i have one jar which runs under win/linux/mac and the user has not to set any paths?

no, java provides no such option.

you can however manually extract the natives somewhere and point to them to get it to work.

Considering natives are usually somewhere relative to the .jar, you could do something like this:
http://lwjgl.org/forum/index.php/topic,3339.msg18482.html#msg18482