我在用Java創建的遊戲中導出的jar有問題。遊戲將於明天發佈,並且該jar不會執行。Jar文件執行錯誤Java/Eclipse
我運行命令java -jar filename.jar
這裏是堆棧跟蹤在命令提示符的一部分:
Image load failed: Resources/Images/shop/jet.png
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at ImageLoader.loadImage(ImageLoader.java:21)
at ImageLoader.loadScaledImage(ImageLoader.java:34)
at ImgButton.<init>(ImgButton.java:18)
at Carnies.createButtons(Carnies.java:343)
at Carnies.simpleInitialize(Carnies.java:82)
at Frame.<init>(Frame.java:90)
at Carnies.<init>(Carnies.java:64)
at CarnieRunner.makeGUI(CarnieRunner.java:62)
at CarnieRunner.<init>(CarnieRunner.java:27)
at CarnieRunner.main(CarnieRunner.java:131)
Exception in thread "main" java.lang.ExceptionInInitializerError
at Carnies.createButtons(Carnies.java:361)
at Carnies.simpleInitialize(Carnies.java:82)
at Frame.<init>(Frame.java:90)
at Carnies.<init>(Carnies.java:64)
at CarnieRunner.makeGUI(CarnieRunner.java:62)
at CarnieRunner.<init>(CarnieRunner.java:27)
at CarnieRunner.main(CarnieRunner.java:131)
Caused by: java.lang.NullPointerException
at GifHandler.<init>(GifHandler.java:15)
at GifHandler.<clinit>(GifHandler.java:7)
... 7 more
它出現的問題是,我的圖片無法載入。下面是在處理圖像加載程序行:
public static BufferedImage loadImage(String fileName) {
try {
File file;
file = new File(fileName);
BufferedImage sub = ImageIO.read(file);
return toCompatibleImage(sub);
}
catch (IOException e) {
System.out.println("Image load failed: " +fileName);
e.printStackTrace();
return null;
}
}
這一切工作在eclipse漂亮,但對罐沒有運氣。任何建議都會很棒。如果讓我的整個項目幫助解決問題,請在github.com/madamsmall/carnie上公開發布 謝謝!
你的圖像保存在哪裏? –
[無法讀取圖像在罐子](http://stackoverflow.com/questions/15243928/cannot-read-image-in-jar)可能重複許多其他人。 –