简体   繁体   中英

Java Slick2D & lwjgl

i try to write the boot screen to test the game. When I try to run this code, I have some errors. I was looking for some information on anything specific but not learned, besides, someone mentioned that I do not have the graphics drivers, but I have graphic drivers :)

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

}

when i try test it i have error:

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)

The lwjgl library isn't in java.library.path. lwjgl bridges java to the openGL libraries via JNI, so you need to have the library (.so or .dll depending on environment) findable to the JVM so it can be loaded.

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

"This is because the native part is not setup correctly. Add a -Djava.library.path=path/to/dir to the commandline or as an VM option in your IDE so that lwjgl is able to find the folder containing the native files."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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