This is my first post on this website. I was following along with ThinMatrix's LWJGL 2 game development tutorial on YouTube. I have seen this error in other posts, but none of them helped. When trying to run, I got this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
    at engineTest.MainGameLoop.main(MainGameLoop.java:10)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 1 more

The code uses LWJGL 2.9.3 and the slick-util library. I am also using JavaSE 10 (In the tutorial he is using 1.8, I don't know if this matters). The error points to line 10 in my main class which is:

DisplayManager.createDisplay();

I will put the rest of my code below. I have triple checked the tutorial for setting up the project with correct jars and natives and have been stumped for a few hours now. Any help would be massively appreciated.

DisplayManager:

package renderEngine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.ContextAttribs;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;

public class DisplayManager {

    private static final int WIDTH = 1280;
    private static final int HEIGHT = 720;
    private static final int FPS_CAP = 120;

    public static void createDisplay() {

        ContextAttribs attribs = new ContextAttribs(3,2);
        attribs.withForwardCompatible(true);
        attribs.withProfileCore(true);

        try {
            Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
            Display.create(new PixelFormat(), attribs);
            Display.setTitle("Game");
        } catch (LWJGLException e) {
            e.printStackTrace();
        }

        GL11.glViewport(0, 0, WIDTH, HEIGHT);

    }

    public static void updateDisplay() {

        Display.sync(FPS_CAP);
        Display.update();

    }

    public static void closeDisplay() {

        Display.destroy();

    }

}

MainGameLoop:

package engineTest;

import org.lwjgl.opengl.Display;
import renderEngine.DisplayManager;

public class MainGameLoop {

    public static void main(String[] args) {

        DisplayManager.createDisplay();

        while(!Display.isCloseRequested()) {

            DisplayManager.updateDisplay();

        }

        DisplayManager.closeDisplay();

    }

}

0 Answers