[英]java.lang.NoClassDefFoundError in LWJGL when attempting to run in Eclipse
So I'm a moderately novice programmer, but after toiling over this error for a while, I can't find a solution. 因此,我是一名中等程度的新手程序员,但是经过一段时间的努力,我找不到解决方案。 I'm making a puzzle game, and for some reason, it just refuses to run now. 我正在制作一个益智游戏,由于某种原因,它现在拒绝运行。 I always get this error: 我总是收到此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.Library
at org.lwjgl.system.MemoryAccess.<clinit>(MemoryAccess.java:22)
at org.lwjgl.system.Pointer.<clinit>(Pointer.java:24)
at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:594)
at Graphics.LaunchWindow.run(LaunchWindow.java:32)
at Graphics.LaunchWindow.main(LaunchWindow.java:96)
Eclipse tells me that none of my code has errors within it, and reinstalling LWJGL doesn't work (I tried both the stable 3.0.0b build 64 and the nightly 3.0.0 build 22). Eclipse告诉我,我的代码中都没有错误,并且重新安装LWJGL不起作用(我尝试了稳定的3.0.0b build 64和夜间的3.0.0 build 22)。 I have seen other similar questions taking about making sure the lwjgl.jar is in the class path, but I've made sure multiple times. 关于确保lwjgl.jar位于类路径中,我已经看到了其他类似的问题,但是我已经多次确认。 Also, if it matters, I have lwjgl_util.jar and slick_util.jar in the class path as well, and even though they are outdated compared to lwjgl 3, removing them from the class path makes no difference. 另外,如果很重要,我在类路径中也有lwjgl_util.jar和slick_util.jar,即使它们与lwjgl 3相比已经过时,将它们从类路径中删除也没有什么区别。
package Graphics;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import Controls.KeyParser;
import Controls.KeyboardInput;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.system.MemoryUtil.*;
public class LaunchWindow {
private GLFWErrorCallback errorCallback;
private GLFWKeyCallback keyCallback;
public int width = 1024;
public int height = 600;
public String title = "Duplicity";
public long fullscreen = NULL;
public long window;
public void run() {
try {
init();
loop();
glfwDestroyWindow(window);
keyCallback.release();
} finally {
glfwTerminate();
errorCallback.release();
}
}
private void init() {
glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));
KeyboardInput.initiate();
if ( glfwInit() != GLFW_TRUE )
throw new IllegalStateException("Unable to initialize GLFW");
if(fullscreen == NULL){
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
}
window = glfwCreateWindow(width, height, title, fullscreen, NULL);
if (window == NULL)
throw new RuntimeException("Failed to create the GLFW window");
glfwSetKeyCallback(window, keyCallback = new GLFWKeyCallback() {
@Override
public void invoke(long window, int key, int scancode, int action, int mods) {
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE )
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
});
GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
glfwSetWindowPos(window, (vidmode.width() - width) / 2, (vidmode.height() - height) / 2);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwShowWindow(window);
keyCallback = GLFWKeyCallback.create(KeyboardInput::glfw_key_callback);
keyCallback.set(window);
/* mouseButtonCallback = GLFWMouseButtonCallback.create(Mouse::glfw_mouse_button_callback);
mouseButtonCallback.set(window);
cursorPosCallback = GLFWCursorPosCallback.create(Mouse::glfw_cursor_pos_callback);
cursorPosCallback.set(window); */
GL.createCapabilities();
}
public void loop() {
GL.createCapabilities();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
while ( glfwWindowShouldClose(window) == GLFW_FALSE ) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
new KeyParser().checkKeyState();
}
}
public static void main(String[] args) {
new LaunchWindow().run();
}
}
Incorrect system library path can be one reason for this error, but this can also be caused by system library incompatibility (on Linux). 不正确的系统库路径可能是导致此错误的原因之一,但这也可能是由于系统库不兼容(在Linux上)引起的。 Code included in LWJGL 3 requires GLIBC version 2.14 or higher. LWJGL 3中包含的代码要求GLIBC版本2.14或更高版本。 If your system (eg Linux) is older (like Debian Wheezy, for example), your GLIBC version will be older than the required one. 如果您的系统(例如Linux)较旧(例如Debian Wheezy),则您的GLIBC版本将比所需的版本更旧。 If that's the case you'll need to install a newer GLIBC version, or upgrade your system (eg to Debian Jessie). 如果是这种情况,则需要安装更新的GLIBC版本或升级系统(例如,升级到Debian Jessie)。 HTH, HTH,
M 中号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.