0

我尝试编写启动屏幕来测试游戏。当我尝试运行此代码时,我遇到了一些错误。我正在寻找一些关于任何具体但未学过的信息,此外,有人提到我没有图形驱动程序,但我有图形驱动程序:)

包 JaAdrian.MyGame;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

public class Main extends BasicGame {

    public static final String NAME = "SampleTest";

    public Main() {
        super(NAME);
    }

    public void render(GameContainer gc, Graphics g){

    }

    @Override
    public void init(GameContainer gc) throws SlickException {

    }

    @Override
    public void update(GameContainer gc, int g) throws SlickException {

    }

    public static void main(String[] args){
        try {
            AppGameContainer app = new AppGameContainer(new Main());

            app.setDisplayMode(800, 600, false); //true == fullscreen
            app.setTargetFrameRate(60);
            app.setAlwaysRender(true);
            app.setUpdateOnlyWhenVisible(false);
            app.start();

        } catch (SlickException e) {
            e.printStackTrace();
        }
    }

}

当我尝试测试它时出现错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at org.lwjgl.Sys$1.run(Sys.java:73)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
    at org.lwjgl.Sys.loadLibrary(Sys.java:95)
    at org.lwjgl.Sys.<clinit>(Sys.java:112)
    at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
    at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:37)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:34)
    at JaAdrian.MyGame.Main.main(Main.java:35)
4

1 回答 1

0

lwjgl 库不在 java.library.path 中。lwjgl 通过 JNI 将 java 桥接到 openGL 库,因此您需要让 JVM 可以找到库(.so 或 .dll 取决于环境)以便加载它。

http://www.lwjgl.org/wiki/index.php?title=Downloading_and_Setting_Up_LWJGL

“这是因为本机部分设置不正确。将 -Djava.library.path=path/to/dir 添加到命令行或作为 IDE 中的 VM 选项,以便 lwjgl 能够找到包含本机文件的文件夹。”

于 2013-01-06T01:50:22.110 回答