获取“java.lang.UnsatisfiedLinkError”:java.library.path 中没有 lwjgl
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19344914/
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
Getting 'java.lang.UnsatisfiedLinkError': no lwjgl in java.library.path
提问by Fund Monica's Lawsuit
Note this is different from this questionbecause it does not deal with linking because it's not asking how to link it via the CLI, but the GUI in Eclipse.
请注意,这与此问题不同,因为它不涉及链接,因为它不询问如何通过 CLI 链接它,而是询问 Eclipse 中的 GUI。
I have been trying to write a simple program using LWJGL. When I add the library to Eclipse (Kepler 4.3.1 on Windows 7 64bit) and write a program, it does not show red squigglies under the the things which use LWJGL. However, trying to run it gives me the following stacktrace:
我一直在尝试使用 LWJGL 编写一个简单的程序。当我将库添加到Eclipse(Windows 7 64位上的Kepler 4.3.1)并编写程序时,它在使用LWJGL的东西下没有显示红色波浪线。但是,尝试运行它会给我以下堆栈跟踪:
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.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:135)
at DisplayExample.start(DisplayExample.java:8)
at DisplayExample.main(DisplayExample.java:23)
(Yes, that is the example they give first, but I wanted to run it to make sure everything was installled properly)
(是的,这是他们首先给出的示例,但我想运行它以确保一切都安装正确)
My question is, how do I fix this error? Note that, even when running in Eclipse, it still fails. If I run something else which does not use LWJGL it works, too. I just downloaded it from the internet - it only had one version, so I assume it was the correct one. From what I can see, none of the other question askers have the same error as me - but if you could point me to informative questions that would be helpful too.
我的问题是,我该如何解决这个错误?请注意,即使在 Eclipse 中运行,它仍然会失败。如果我运行其他不使用 LWJGL 的东西,它也可以工作。我刚刚从互联网上下载了它 - 它只有一个版本,所以我认为它是正确的。从我所看到的,其他提问者都没有和我一样的错误——但如果你能指出我的信息性问题也会有帮助。
采纳答案by FreelanceCoder
You don't have the natives set up in your LWJGL application.
您没有在 LWJGL 应用程序中设置本机。
Here's how to do it:
这是如何做到的:
- Go to your LWJGL folder that contains the folders named "jar", "res", "doc", and "native". You need to go into Eclipse (assuming you use eclipse), open your project in the Project Explorer on the left side of your screen.
- Right click on the "JRE System Library" of your project, and click "Build Path" -> "Configure Build Path".
- Include the LWJGL native libraries to your project in the Build Path Configurer by clicking the "Native library location" which can be seen in the JRE System Library dropdown menu.
- Click on "Edit...", which will be the only button clickable in that general area.
- A file explorer will pop up. Navigate to the location of your LWJGL native folder (The location should be something like "C:\Users\YOURUSERNAMEHERE\Desktop\Java\eclipse\lwjgl-2.9.0\native" if you are using Windows) and include the folder named [Your OS here].
- 转到包含名为“jar”、“res”、“doc”和“native”的文件夹的 LWJGL 文件夹。您需要进入 Eclipse(假设您使用 eclipse),在屏幕左侧的 Project Explorer 中打开您的项目。
- 右键单击您项目的“JRE 系统库”,然后单击“构建路径”->“配置构建路径”。
- 通过单击可在 JRE 系统库下拉菜单中看到的“本机库位置”,将 LWJGL 本机库包含到您的项目中的构建路径配置器中。
- 单击“编辑...”,这将是该一般区域中唯一可单击的按钮。
- 将弹出一个文件浏览器。导航到 LWJGL 本机文件夹的位置(如果您使用的是 Windows,该位置应该类似于“C:\Users\YOURUSERNAMEHERE\Desktop\Java\eclipse\lwjgl-2.9.0\native”)并包含名为 [你的操作系统在这里]。
Hope this helped :)
希望这有帮助:)
回答by Fund Monica's Lawsuit
I was following the tutorial here, and it looks like I didn't do the Adding the nativesstep, or I did it incorrectly.
我正在关注这里的教程,看起来我没有执行添加本地人步骤,或者我做错了。
Follow the instructions in that link and the problem should be resolved:
按照该链接中的说明操作,应该可以解决问题:
This is done by clicking the little arrow next to the lwjgl.jar file to show the drop down list. Double click 'Native library location' and select the folder that contains the native files for your operating system and clicking OK. These are located in the natives folder include in the LWJGL download bundle (e.g. On Windows you'd point to the natives\windows folder which contains the *.dll files, On Mac you'd point to the natives/macosx folder and on Linux you'd point to the natives/linux folder).
这是通过单击 lwjgl.jar 文件旁边的小箭头显示下拉列表来完成的。双击“本机库位置”并选择包含操作系统本机文件的文件夹,然后单击“确定”。这些位于 LWJGL 下载包中的 natives 文件夹中(例如,在 Windows 上,您将指向包含 *.dll 文件的 natives\windows 文件夹,在 Mac 上,您将指向 natives/macosx 文件夹,在 Linux 上你会指向 natives/linux 文件夹)。