简体   繁体   English

我的java游戏在eclipse中运行,但一旦导出它“找不到LWJGL”并且不会运行

[英]My java game runs in eclipse, but once exported it “can't find LWJGL” and won't run

I made a Java game in eclipse and when I run the executable .jar it starts up, and the loading screen starts, but then it stops and hangs. 我在eclipse中制作了一个Java游戏,当我运行可执行文件.jar时,它启动,加载屏幕启动,但随后停止并挂起。 I ran it using the command line: "Java -jar filename.jar" and when the loading screen stops it displays an error. 我使用命令行运行它:“Java -jar filename.jar”,当加载屏幕停止时,它显示错误。 This is what the cmd shows: 这就是cmd显示的内容:

E:\>Java -jar Speedrunner.jar
60Ticks, FPS:1447
60Ticks, FPS:1627
60Ticks, FPS:1380
Wed Mar 19 12:02:27 GMT 2014 INFO:Initialising sounds..
Exception in thread "Thread-2" 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.openal.AL.<clinit>(AL.java:59)
    at org.newdawn.slick.openal.SoundStore$1.run(SoundStore.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.newdawn.slick.openal.SoundStore.init(SoundStore.java:292)
    at org.newdawn.slick.Sound.<init>(Sound.java:83)
    at com.daves.first_Scroller.utils.AudioPlayer.addSound(AudioPlayer.java:29)
    at com.daves.first_Scroller.utils.ResourceLoader.loadSounds(ResourceLoader.java:35)
    at com.daves.first_Scroller.Game.load(Game.java:110)
    at com.daves.first_Scroller.Game.tick(Game.java:160)
    at com.daves.first_Scroller.Game.run(Game.java:228)
    at java.lang.Thread.run(Unknown Source)

This is saying that LWJGL isn't in java.library.path I've gone to my game in the workspace and configured the build path to include all the libraries and to include them in the .jar when I export my game but I'm still getting the same problem. 这就是说LWJGL不在java.library.path中我已经在工作区中进入我的游戏并配置了构建路径以包含所有库并在我导出游戏时将它们包含在.jar中但是我'我仍然遇到同样的问题。 Does anyone know what I need to do to get this to work? 有谁知道我需要做些什么才能让它发挥作用? (I looked in the .jar and LWJGL is there in the org file) (我查看了.jar和LWJGL在org文件中)

Export lwjgl library in your jar. 在jar中导出lwjgl库。

To do this, right click on the project, properties, java build path, order & export, check your library 要执行此操作,请右键单击项目,属性,java构建路径,订购和导出,检查您的库

Set the (native) library path in the command line: 在命令行中设置(本机)库路径:

Java -Djava.library.path=path/to/dir -jar filename.jar

Where dir : dir

[...] should contain the native part (*.dll files on windows, *.so on linux, *.jnilib on mac, etc) [...]应该包含原生部分(Windows上的* .dll文件,linux上的* .so,mac上的* .jnilib等)

( Source ) 来源

You need to do two things: you need to include the LWJGL classes on your classpath (or in your jar), and you need to include the natives in your library path. 您需要做两件事:您需要在类路径(或jar中)中包含LWJGL类,并且需要在库路径中包含本机。

Exporting from eclipse doesn't automatically include your library path, which is why you're getting your error. 从eclipse导出不会自动包含您的库路径,这就是您收到错误的原因。

A utility like JarSplice or SvgExe can help with both of these things. JarSpliceSvgExe这样的实用程序可以帮助完成这两件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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