2016-02-08 40 views
1

所以我是一个适度的新手程序员,但在苦苦寻找这个错误一段时间后,我找不到解决方案。我正在制作益智游戏,出于某种原因,它现在拒绝运行。我总是得到这个错误:LWJGL中的java.lang.NoClassDefFoundError当试图在Eclipse中运行时

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构建64和夜间3.0.0建立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(); 
} 
} 
+1

这已经回答了。看到解决方案[这里](http://stackoverflow.com/questions/34459196/org-lwjgl-system-library-error)。 –

+0

我正在努力解决同样的问题,但在我的情况下,这是相反的。它在Eclipse中工作,但不是从命令行(包括本地路径)。它与_LWJGL 3.0.0a_一起工作,但是由于我更新到_3.0.0b_,我得到这个错误。 –

回答

0

不正确的系统库路径可能是此错误的原因之一,但这也可能是系统库不兼容(在Linux上)导致的。包含在LWJGL 3中的代码需要GLIBC版本2.14或更高版本。如果您的系统(例如Linux)较旧(例如Debian Wheezy),则您的GLIBC版本将比所需的版本旧。 如果出现这种情况,您需要安装更新的GLIBC版本,或升级您的系统(例如Debian Jessie)。 HTH,

M

相关问题