无法启动LWJGL应用程序

时间:2017-08-04 21:29:19

标签: java maven lwjgl

我正在尝试用LWJGL制作简单的Tic-Tac-Toe游戏(第一次)。

这是我的启动命令:

java -jar TicTacToe-0.1.0-SNAPSHOT-jar-with-dependencies.jar

这是Main class:

public class Main implements Runnable {

    protected static final Main instance = new Main();
    private boolean running;

    public static void main(String[] args) {
        Thread thread = new Thread(Main.instance);
        thread.start();
    }

    @Override
    public void run() {
        this.init();

        while(running) {

        }
    }

    private void init() {
        try {
            Display.setDisplayMode(new DisplayMode(1280, 720));
            Display.setTitle("Tic-Tac-Toe");
            Display.setResizable(false);
            Display.setLocation(100, 100);
            Display.setVSyncEnabled(false);
            Display.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
        }

        running = true;
    }
}

这是来自Maven的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.azoraqua</groupId>
    <artifactId>TicTacToe</artifactId>
    <version>0.1.0-SNAPSHOT</version>

    <name>${project.artifactId}-${project.version}</name>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <lwjgl.version>3.1.2</lwjgl.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>

                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>com.azoraqua.tictactoe.Main</mainClass>
                        </manifest>
                    </archive>

                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.lwjgl.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>2.9.3</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>lwjgl-natives-linux</id>

            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>

            <properties>
                <lwjgl.natives>natives-linux</lwjgl.natives>
            </properties>
        </profile>

        <profile>
            <id>lwjgl-natives-macos</id>

            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>

            <properties>
                <lwjgl.natives>natives-macos</lwjgl.natives>
            </properties>
        </profile>

        <profile>
            <id>lwjgl-natives-windows</id>

            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>

            <properties>
                <lwjgl.natives>natives-windows</lwjgl.natives>
            </properties>
        </profile>
    </profiles>
</project>

但是当我尝试启动它时,会抛出java.lang.UnsatifiedLinkError;

Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: no lwjgl64 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:72)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
        at org.lwjgl.Sys.loadLibrary(Sys.java:87)
        at org.lwjgl.Sys.<clinit>(Sys.java:117)
        at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
        at com.azoraqua.tictactoe.Main.init(Main.java:28)
        at com.azoraqua.tictactoe.Main.run(Main.java:19)
        at java.lang.Thread.run(Unknown Source)

据我所知,它与一些本地库等有关,但我不知道如何实际修复它。

0 个答案:

没有答案