简体   繁体   English

LibGDX运行错误“ ClassNotFoundException”

[英]LibGDX running error “ClassNotFoundException”

I've created a Java LibGDX project in Eclipse and haven't edited anything other than the window's title and the dimensions of the window. 我已经在Eclipse中创建了Java LibGDX项目,除了窗口的标题和窗口的尺寸之外,没有进行任何其他编辑。 When running the project it returns the following error: 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 运行项目时,它将返回以下错误: 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

I never used to have this issue and it has only just began occurring in this new project. 我从来没有遇到过这个问题,它只是在这个新项目中才刚刚开始发生。

Code

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);
    }
}

Other class: 其他类:

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

To develop your application via Eclipse, you need to install the 要通过Eclipse开发应用程序,您需要安装

following pieces of software. 以下软件。 You can find an in depth guide HERE : 您可以在此处找到详细指南:

See also: 也可以看看:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM