我在Eclipse中創建了一個Java LibGDX項目,並沒有編輯窗口的標題和窗口的尺寸以外的任何東西。運行該項目時,返回以下錯誤: Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/jnigen/NativeCodeGenerator at com.badlogic.gdx.physics.bullet.BulletBuild.main(BulletBuild.java:32) Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.jnigen.NativeCodeGenerator at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more
LibGDX運行錯誤「ClassNotFoundException」
我從來沒有遇到過這個問題,它只是剛剛開始發生在這個新項目中。
代碼
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import de.matthiasmann.twlthemeeditor.Main;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.title = "AI Path Finding";
config.width = Main.WIDTH;
config.height = Main.HEIGHT;
new LwjglApplication(new Game(), config);
}
}
其他類:
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Game extends ApplicationAdapter {
private final static int WIDTH = 800;
private final static int HEIGHT = 800;
SpriteBatch batch;
Texture img;
@Override
public void create() {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
}
您使用的是gradle集成嗎? – 2014-10-12 14:52:37