LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Zombiedevice on May 21, 2010, 20:26:04

Title: Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
Post by: Zombiedevice on May 21, 2010, 20:26:04
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:



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 . . .
Title: Re: Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
Post by: Endolf on May 22, 2010, 09:25:25
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
Title: Re: Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
Post by: mmisc on May 22, 2010, 12:05:21
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?
Title: Re: Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
Post by: kappa on May 22, 2010, 12:06:57
Quote from: mmisc on May 22, 2010, 12:05:21
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.
Title: Re: Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
Post by: Ciardhubh on May 22, 2010, 16:16:08
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