gpt4 book ai didi

java - 从 eclipse 导出我的 Java 游戏,运行时出现错误

转载 作者:行者123 更新时间:2023-12-02 06:03:50 24 4
gpt4 key购买 nike

我在 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 文件,它包含它需要的所有字体和 Sprite ,并且当我导出它时,Eclipse 将所需的所有库打包到 .jar 中。

最佳答案

看起来像这个文件:

.\resources\Fonts\tight_pixel.ttf

不包含在您的 jar 中。当您从 Eclipse 执行项目时,它可能在您的类路径中可用,因此您没有注意到它。

关于java - 从 eclipse 导出我的 Java 游戏,运行时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22454296/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com