[英]Marathon JAVA Driver - Error when running inside an exported JAR file from Eclipse
[英]Exported my Java game from eclipse, and it gets an error when running
我在eclipse中制作了一个Java游戏,当我运行可执行文件.jar时,它启动,加载屏幕启动,但随后停止并挂起。 我使用命令行运行它:“Java -jar filename.jar”,当加载屏幕停止时,它显示错误。 这就是cmd显示的内容:
D:\>java -jar Speedrunner.jar
60Ticks, FPS:1637
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at com.daves.first_Scroller.utils.BufferedImageLoader.loadImage(Buffered
ImageLoader.java:26)
at com.daves.first_Scroller.utils.ResourceLoader.loadImages(ResourceLoad
er.java:17)
at com.daves.first_Scroller.Game.load(Game.java:100)
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)
60Ticks, FPS:1744
java.io.IOException: Can't read .\resources\Fonts\tight_pixel.ttf
at java.awt.Font.createFont(Unknown Source)
at com.daves.first_Scroller.utils.Fonts.registerFont(Fonts.java:36)
at com.daves.first_Scroller.utils.Fonts.<init>(Fonts.java:28)
at com.daves.first_Scroller.utils.ResourceLoader.loadFonts(ResourceLoader.java:30)
at com.daves.first_Scroller.Game.load(Game.java:105)
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)
60Ticks, FPS:1761
Mon Mar 17 12:18:08 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)
编辑 - 我查看.jar文件,它包含它需要的所有字体和精灵,当我导出时,eclipse将所有需要的库打包到.jar中。
好像这个文件:
.\resources\Fonts\tight_pixel.ttf
不包括在你的罐子里。 当您从Eclipse执行项目时,它可能在您的类路径中可用,因此您没有注意到它。
你需要告诉java在哪里寻找LWJGL库。 将以下内容添加到命令行:
-Djava.library.path=path/to/dir
从文档:
我一直得到一个java.lang.UnsatisfiedLinkError:java.library.path中没有lwjgl
这是因为未正确设置本机部分。 将-Djava.library.path = path / to / dir添加到命令行或IDE中的VM选项,以便lwjgl能够找到包含本机文件的文件夹。
外部链接: http ://www.lwjgl.org/wiki/index.php?title = Downloading_and_Setting_Up_LWJGL
似乎找不到。\\ resources \\ Fonts \\ tight_pixel.ttf。 那可能是因为在你从另一条路上跑过你的游戏之前。 (或者你没有将它包含在你的包中)
.jar
文件中缺少.\\resources\\Fonts\\tight_pixel.ttf
文件。
那就是java.io.IOException: Can't read .\\resources\\Fonts\\tight_pixel.ttf
行java.io.IOException: Can't read .\\resources\\Fonts\\tight_pixel.ttf
告诉你。
要解决此问题,请将文件夹resources
集成到路径中。 然后它被集成到导出的.jar
文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.