所以我是一个中等程度的新手程序员,但是经过一段时间的这个错误,我找不到解决方案。我正在制作一个益智游戏,由于某种原因,它现在只是拒绝运行。我总是得到这个错误:
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告诉我,我的代码中没有任何错误,重新安装LWJGL不起作用(我尝试了稳定的3.0.0b build 64和nightly 3.0.0 build 22)。我已经看到了其他类似的问题,确保lwjgl.jar在类路径中,但我确保多次。另外,如果重要的话,我在类路径中也有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();
}
}
答案 0 :(得分:0)
错误的系统库路径可能是此错误的一个原因,但这也可能是由系统库不兼容引起的(在Linux上)。 LWJGL 3中包含的代码需要GLIBC 2.14或更高版本。如果您的系统(例如Linux)较旧(例如Debian Wheezy),则您的GLIBC版本将比所需版本旧。 如果是这种情况,您需要安装较新的GLIBC版本,或升级您的系统(例如,升级到Debian Jessie)。 HTH,
中号