Answer the question
In order to leave comments, you need to log in
How to fix "Unable to initialize main class" error in Eclipse when using LWJGL?
Tried to run some simple Java code using LWJGL in Eclipse:
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class Main {
static int width = 800, height = 600;
static DisplayMode mainDisplayMode = new DisplayMode(width, height);
static boolean running = true;
static void update() {
if (Display.wasResized()) {
width = Display.getWidth();
height = Display.getHeight();
}
Display.update();
Display.sync(60);
if (Display.isCloseRequested()) {
running = false;
}
}
public static void main(String[] args) {
try {
Display.setLocation(
(Display.getDesktopDisplayMode().getWidth() - mainDisplayMode.getWidth() / 2,
Display.getDesktopDisplayMode().getHeight() - mainDisplayMode.getHeight() / 2);
Display.setResizable(true);
Display.setVSyncEnabled(true);
Display.setDisplayMode(mainDisplayMode);
Display.create();
} catch (LWJGLException ex) {
System.err.println(ex.getStackTrace().toString());
Display.destroy();
System.exit(1);
}
while (running) {
update();
}
Display.destroy();
System.exit(0);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question