2015-01-27 99 views
0

例外出於某種原因,日食只是做它自己的東西.. 我有lwjgl.jar & -util.jar & slick.util Java構建路徑 藏漢內罐..Java中,線程主要LWJGL

代碼:

package Com.Window; 

import org.lwjgl.LWJGLException; 
import org.lwjgl.opengl.Display; 
import org.lwjgl.opengl.DisplayMode; 

public class Window { 

    public void start() { 

     try { 
      Display.setDisplayMode(new DisplayMode(800, 600)); 
      Display.create(); 
     } catch (LWJGLException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

     // init OpenGL here 

     while(!Display.isCloseRequested()) { 

      // render OpenGL here 

      Display.update(); 
     } 
     Display.destroy(); 

    } 
    public static void main(String[] args) { 
     Window window = new Window(); 
     window.start(); 
    } 
} 

錯誤:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path 
    at java.lang.ClassLoader.loadLibrary(Unknown Source) 
    at java.lang.Runtime.loadLibrary0(Unknown Source) 
    at java.lang.System.loadLibrary(Unknown Source) 
    at org.lwjgl.Sys$1.run(Sys.java:73) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66) 
    at org.lwjgl.Sys.loadLibrary(Sys.java:95) 
    at org.lwjgl.Sys.<clinit>(Sys.java:112) 
    at org.lwjgl.opengl.Display.<clinit>(Display.java:135) 
    at Com.Window.Window.start(Window.java:12) 
    at Com.Window.Window.main(Window.java:32) 

回答

0

1: 創建.BAT˚F ILE並把-Djava.library.path = 「LIB /」

2. 做它編程(第一行代碼)

System.setProperty("org.lwjgl.librarypath", System.getProperty("user.dir") + "/lib/"); 
0

添加到JClassics answer

如果你不停的文件結構從LWJGL包你可以使用這樣的事情:

switch(LWJGLUtil.getPlatform()) 
{ 
    case LWJGLUtil.PLATFORM_WINDOWS: 
    { 
     JGLLib = new File("./native/windows/"); 
    } 
    break; 

    case LWJGLUtil.PLATFORM_LINUX: 
    { 
     JGLLib = new File("./native/linux/"); 
    } 
    break; 

    case LWJGLUtil.PLATFORM_MACOSX: 
    { 
     JGLLib = new File("./native/macosx/"); 
    } 
    break; 
} 

System.setProperty("org.lwjgl.librarypath", JGLLib.getAbsolutePath());