我在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
我从来没有遇到过这个问题,它刚刚开始在这个新项目中出现。
代码
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();
}
}
答案 0 :(得分:0)
要通过Eclipse开发应用程序,需要安装
以下软件。您可以找到深入指南HERE:
Java开发工具包7 + ( JDK )(6将无效!):http://www.oracle.com/technetwork/java/javase/downloads/index.html
Android SDK :http://developer.android.com/sdk/installing.html
Eclipse的Android开发工具:
https://dl-ssl.google.com/android/eclipse/(使用此链接作为eclipse的更新站点)
Eclipse Integration Gradle :
http://dist.springsource.com/snapshot/TOOLS/gradle/nightly(for
Eclipse 4.4)或http://dist.springsource.com/release/TOOLS/gradle(for
Eclipse< 4.4)
另见: