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. I ran it using the command line: "Java -jar filename.jar" and when the loading screen stops it displays an error. This is what the cmd shows:
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)
EDIT - I looked in the .jar file and it contains all the Fonts and sprites it needs, and eclipse packaged all libraries needed into the .jar when I exported it.
Seems like this file:
.\resources\Fonts\tight_pixel.ttf
is not included on your jar. Probably it was available on your classpath when you executed your project from Eclipse, so you didn't notice it.
You need to tell java where to look for the LWJGL library. Add the following to the command line:
-Djava.library.path=path/to/dir
From the documentation:
I keep getting an java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
This is because the native part is not setup correctly. Add a -Djava.library.path=path/to/dir to the commandline or as an VM option in your IDE so that lwjgl is able to find the folder containing the native files.
External link: http://www.lwjgl.org/wiki/index.php?title=Downloading_and_Setting_Up_LWJGL
It seems that .\\resources\\Fonts\\tight_pixel.ttf is not found. That may be because before you were running you game from another path. (Or you didn't include it in your package)
The file .\\resources\\Fonts\\tight_pixel.ttf
is missing in your .jar
file.
That's, what the line java.io.IOException: Can't read .\\resources\\Fonts\\tight_pixel.ttf
tells you.
To solve it, integrate the folder resources
into the path. Then it's integrated into your exported .jar
file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.