I've seen this answer: Add image to JAR Java But I didn't understand how does it work. I'll try to explain step-by-step.
At the begining I add image to my project
- test
- src
- com.test
- tester.java
- img.png
- com.test
- images
- img.png
- JRE System Library
- src
My question - where should I place my img.png?
Then I try to get it from resource
URL url = tester.class.getResource(PATH);
ImageIcon ii = new ImageIcon(url);
I've tried different pathes like bellow:
- "images/img.png" - it doesn't work. ii has wrong size and etc
- "/images/img.png" - it doesn't work at all.
Could you tell me what I'm doing wrong? if it isn't difficult for you, please step-by-step.
Guys, I've taken note that if I have an url with large length, I can't see images, but if I copy file onto C:(for example), I can see it. What's happened? Is it bug? By the way, my url contains !!! symbols.