1

I know this has been answered before but none have worked. I tried to run a simple program,

enter code here
package tools.crystalcoffee.methods;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class DisplayMethod {
public void createDisplay(int width, int height) {
    try {
        //Here we set the size of the Display then create it
        Display.setDisplayMode(new DisplayMode(width,height));
        Display.create();
    } catch (LWJGLException e) {

        e.printStackTrace();
    }

    // init OpenGL here

    while (!Display.isCloseRequested()) {

        // render OpenGL here

        Display.update();
    }

    Display.destroy();
    }


public static void main(String[] argv) {
    //Make a debug thing
    Debug debug = new Debug();

    debug.debug("Works");

    //Making an instance?
    DisplayMethod displayExample = new DisplayMethod();

    //Starting
    displayExample.createDisplay(100,100);
}

}

But it always throws the same error, no matter if I add the native files or not.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
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 tools.crystalcoffee.methods.DisplayMethod.createDisplay(DisplayMethod.java:11)
at tools.crystalcoffee.methods.DisplayMethod.main(DisplayMethod.java:38)

I have looked everywhere for an answer, for 2 hours straight and thats ALL it throws. Help?

  • 1
    Are you perhaps trying to load a 64-bit library from a 32-bit Elipse/JVM? And remember, the file has to be named `liblwjgl.so`, not `liblwjgl64.so` – Andreas May 28 '16 at 00:52
  • 1
    @Andreas I have. It is called liblwjgl.so and it has changed nothing, it still says the same thing. – TheDeadCrafter May 28 '16 at 01:22
  • 1
    Are the native files linked to the LWJGL library in Project Properties > Build Path > Libraries? – CConard96 May 28 '16 at 13:46
  • 1
    @TheDeadCrafter The program works for me. Did you try and link lwjgl 2.9 libraries? You might get this error if you mix v2 and v3 libraries or if you don't include the natives. Please try read my answer and comment if it doesn't work for you. I got it working for me in eclipse and the window opens. Pretty nice actually. – Niklas Rosencrantz May 31 '16 at 06:05

2 Answers2

1

Check your properties for lwjgl. I tried your program and first I got the same error (Unsatisfied link). Then if I make sure that all libraries are lwjgl 2.9.3 (get it from the legacy.lwjgl), then it works and the display starts rendering.

The exception we had seems to be becuase we had mixed versions of lwjgl 3 and 2.

enter image description here

See also LWJGL Display class can't be found

And Getting 'java.lang.UnsatisfiedLinkError': no lwjgl in java.library.path

Community
  • 1
  • 1
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
0

I found this somewhere else, and it made it all work for me:

System.setProperty("org.lwjgl.librarypath", new File("/home/cole/Documents/lwjgl-2.9/lwjgl-2.9.0/native/linux").getAbsolutePath());