2013-01-06 80 views
0

我嘗試編寫引導屏幕來測試遊戲。當我嘗試運行此代碼時,出現了一些錯誤。我正在尋找一些有關任何具體但沒有學到的信息,另外,有人提到我沒有圖形驅動程序,但我有圖形驅動程序:)Java Slick2D&lwjgl

package JaAdrian.MyGame;

import org.newdawn.slick.AppGameContainer; 
import org.newdawn.slick.BasicGame; 
import org.newdawn.slick.GameContainer; 
import org.newdawn.slick.Graphics; 
import org.newdawn.slick.SlickException; 

public class Main extends BasicGame { 

    public static final String NAME = "SampleTest"; 

    public Main() { 
     super(NAME); 
    } 

    public void render(GameContainer gc, Graphics g){ 

    } 

    @Override 
    public void init(GameContainer gc) throws SlickException { 

    } 

    @Override 
    public void update(GameContainer gc, int g) throws SlickException { 

    } 

    public static void main(String[] args){ 
     try { 
      AppGameContainer app = new AppGameContainer(new Main()); 

      app.setDisplayMode(800, 600, false); //true == fullscreen 
      app.setTargetFrameRate(60); 
      app.setAlwaysRender(true); 
      app.setUpdateOnlyWhenVisible(false); 
      app.start(); 

     } catch (SlickException e) { 
      e.printStackTrace(); 
     } 
    } 

} 

當我嘗試測試它,我有錯誤:

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:132) 
    at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:37) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:34) 
    at JaAdrian.MyGame.Main.main(Main.java:35) 

回答

0

的LWJGL庫不在的java.library.path。 lwjgl通過JNI將java橋接到openGL庫,因此您需要擁有可供JVM加載的庫(.so或.dll,具體取決於環境)。

http://www.lwjgl.org/wiki/index.php?title=Downloading_and_Setting_Up_LWJGL

「這是因爲本地部分未正確設置。一個-Djava.library.path =路徑/到/ dir添加到命令行或在IDE的VM選項,以便LWJGL是能夠找到包含本機文件的文件夾。「