LibGDX运行错误" ClassNotFoundException"

时间:2014-10-12 13:00:57

标签: java libgdx

我在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();
    }
}

1 个答案:

答案 0 :(得分:0)

要通过Eclipse开发应用程序,需要安装

以下软件。您可以找到深入指南HERE

另见:

https://github.com/libgdx/libgdx/wiki/Setting-up-your-Development-Environment-(Eclipse,-Intellij-IDEA,-NetBeans)