Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java error no lwjgl64 in path?

I'm trying to make a game and it runs fine in eclipse, but I get this error when I export and run it as a jar file.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl64 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:66)
    at org.lwjgl.Sys.loadLibrary(Sys.java:87)
    at org.lwjgl.Sys.<clinit>(Sys.java:117)
    at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
    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 ultra.game.core.MainGame.main(MainGame.java:1827)

I have tried so many things. I set the natives location to the native folder and I checked inside and lwjgl64 is in there. Any help?

like image 413
Ultrabyte Avatar asked Mar 17 '23 00:03

Ultrabyte


2 Answers

LWJGL uses its own variables for the path to the native libraries:

System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());

If you kept the file structure from the LWJGL package you can use something like this:

switch(LWJGLUtil.getPlatform())
{
    case LWJGLUtil.PLATFORM_WINDOWS:
    {
        JGLLib = new File("./native/windows/");
    }
    break;

    case LWJGLUtil.PLATFORM_LINUX:
    {
        JGLLib = new File("./native/linux/");
    }
    break;

    case LWJGLUtil.PLATFORM_MACOSX:
    {
        JGLLib = new File("./native/macosx/");
    }
    break;
}

System.setProperty("org.lwjgl.librarypath", JGLLib.getAbsolutePath());
like image 101
Dawnkeeper Avatar answered Mar 28 '23 14:03

Dawnkeeper


This means that you do not have the native library named "lwjgl64" in a place so that Java can find and load it, or that you are using a 32-bit JVM and you are trying to load a 64-bit native library (or vice versa) - if you want to use native libraries, they must have the same "bitness" as the JVM you are using.

On Windows, the native library would be in a file lwjgl64.dll; on Mac OS X or other Unix-like systems it would be lwjgl64.so. Find this file, and then set the system property java.library.path using the -D option when you start your program, for example:

java -Djava.library.path=C:\MyProject\lib com.mypackage.MyProgram

where C:\MyProject\lib would be the directory that contains the DLL.

like image 38
Jesper Avatar answered Mar 28 '23 12:03

Jesper