When I run my jar file, i get a javax.imageio.IIOException: Can't read input file!
But the file is in the jar!
the code:
try {imgs.put("player1" , ImageIO.read(new File("/car1.png")));}
catch (IOException e) {System.out.println(e);}
I have tried to put car1.png everywhere in the jar file but its not working.
You probably want to do this instead.
InputStream is = getClass().getResourceAsStream("car1.png");
ImageIO.read(is);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With