First of all, image resources are either obtained from the network or called locally.
This problem does not occur with network access.
Local call
1. Use relative path
URL url=this.getClass().getResource(“/image/timg.jpg”);
ImageIcon background = new ImageIcon(url);
2. When eclipse opens the jar package, check the image folder, as well as the .classpath and .project on the right.
I just didn’t check the image folder, so the exe file cannot load the picture.
3. Use exe4j to complete the package
4. After the packaging is completed, there is no need for the exe and image to be in the same directory. A single exe file can be run to load the image. You
can find that the icon and background image in the upper left corner can be directly loaded.