2
這是我的代碼:錯誤! AppGameContainer拋出java.lang.ClassNotFoundException
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
public class Game extends StateBasedGame{
public static final String gamename = "Ham Blaster!";
public static final int menu = 0;
public static final int play = 1;
public Game(String gamename) {
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));
}
public void initStatesList(GameContainer gc) throws SlickException{
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.enterState(menu);
}
//This create the window
public static void main(String[] args){
AppGameContainer appgc;
try{
appgc = new AppGameContainer(new Game(gamename));
appgc.setDisplayMode(640, 360, false);
appgc.start();
}catch(SlickException e){
e.printStackTrace();
}
}
}
這是它讓我的錯誤:
exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
at JavaGame.Game.main(Game.java:28)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
所以它讓我的類沒有發現錯誤,我試圖再次添加罐子,但它仍然給我的錯誤。 所以請幫助我,我檢查圖書館,它告訴我,班級在那裏,但不是來源。
這個截圖與lib文件夾:
能告訴你的截圖你/ lib文件夾?您是否將該jar添加到您的構建路徑中?這是如何:http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29 – 2014-12-03 00:22:12
你如何運行它? – 2014-12-04 22:58:19
看起來你的類路徑中沒有LWJGL jar *在運行時* – Gus 2014-12-04 23:01:48