I made an application that uses several images. I have 2 ways to run my app:
- press run
in idea
- make a fat jar file and run it from console java -jar app.jar
If I want to run it from Idea
I have to use:
BufferedImage backgroundImage = ImageIO.read(new File("res/field.png"));
instead of
BufferedImage backgroundImage = ImageIO.read(getClass().getClassLoader().getResource("res/field.png"));
<- that's what I have to use in jar file case
Why? I thought that they're about the same. Is there any universal way for my case?