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

Started by Zombiedevice, May 21, 2010, 20:26:04

Previous topic - Next topic

Zombiedevice

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 . . .

Endolf

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

mmisc

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?

kappa

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.

Ciardhubh