0
我認爲我的可執行jar文件不工作,因爲我正在使用的圖像沒有被加載。當我做了一個批處理文件並運行罐子它說jar文件不能正常工作,因爲圖像
"IllegalArgumentException: input == null!"
程序完美的作品,當我在Eclipse中運行它。所以我的問題是,你需要做一些特殊的圖像,才能正確運行jar文件?
代碼,我認爲導致錯誤:
BufferedImage image = ImageIO.read(Sprite.class.getResource(path));
this.width = image.getWidth();
this.height = image.getHeight();
this.pixels = new int[width * height];
image.getRGB(x, y, width, height, pixels, 0, width);
編輯:程序工作正常蝕(圖像加載),當我出口它作爲一個可執行的JAR文件的程序不能正常工作,它只是。
你能提供一些你的代碼嗎? – WIR3D
路徑錯誤。檢查類似的問題,看看它應該是什麼。 –
我嘗試使用類似問題的代碼,但這使得它將文件作爲圖像加載,並且java表示它無法投射到BufferedImage。有沒有辦法讓我變成BufferedImage? – kneedhelp