eclipse Java 错误在路径中没有 lwjgl64?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30346632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:38:34  来源:igfitidea点击:

Java error no lwjgl64 in path?

javaeclipsejarlwjgl

提问by Ultrabyte

I'm trying to make a game and it runs fine in eclipse, but I get this error when I export and run it as a jar file.

我正在尝试制作一个游戏并且它在 eclipse 中运行良好,但是当我将它导出并作为 jar 文件运行时出现此错误。

Exception in thread "main" 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.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 org.newdawn.slick.AppGameContainer.run(AppGameContainer.java:39)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)
    at ultra.game.core.MainGame.main(MainGame.java:1827)

I have tried so many things. I set the natives location to the native folder and I checked inside and lwjgl64 is in there. Any help?

我已经尝试了很多东西。我将 natives 位置设置为 native 文件夹,然后检查内部,lwjgl64 就在那里。有什么帮助吗?

回答by Jesper

This means that you do not have the native library named "lwjgl64" in a place so that Java can find and load it, or that you are using a 32-bit JVM and you are trying to load a 64-bit native library (or vice versa) - if you want to use native libraries, they must have the same "bitness" as the JVM you are using.

这意味着您在某个地方没有名为“lwjgl64”的本机库,以便 Java 可以找到并加载它,或者您正在使用 32 位 JVM 并且您正在尝试加载 64 位本机库(或反之亦然) - 如果您想使用本机库,它们必须与您使用的 JVM 具有相同的“位数”。

On Windows, the native library would be in a file lwjgl64.dll; on Mac OS X or other Unix-like systems it would be lwjgl64.so. Find this file, and then set the system property java.library.pathusing the -Doption when you start your program, for example:

在 Windows 上,本机库将在一个文件中lwjgl64.dll;在 Mac OS X 或其他类 Unix 系统上,它将是lwjgl64.so. 找到此文件,然后在启动程序时java.library.path使用该-D选项设置系统属性,例如:

java -Djava.library.path=C:\MyProject\lib com.mypackage.MyProgram

where C:\MyProject\libwould be the directory that contains the DLL.

C:\MyProject\lib包含 DLL 的目录在哪里。

回答by Dawnkeeper

LWJGL uses its own variables for the path to the native libraries:

LWJGL 使用自己的变量作为本地库的路径:

System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());

If you kept the file structure from the LWJGL package you can use something like this:

如果您保留了 LWJGL 包中的文件结构,您可以使用以下内容:

switch(LWJGLUtil.getPlatform())
{
    case LWJGLUtil.PLATFORM_WINDOWS:
    {
        JGLLib = new File("./native/windows/");
    }
    break;

    case LWJGLUtil.PLATFORM_LINUX:
    {
        JGLLib = new File("./native/linux/");
    }
    break;

    case LWJGLUtil.PLATFORM_MACOSX:
    {
        JGLLib = new File("./native/macosx/");
    }
    break;
}

System.setProperty("org.lwjgl.librarypath", JGLLib.getAbsolutePath());