After exe4j is packaged into an exe file, the picture cannot be displayed

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.
insert image description here
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
insert image description here
insert image description here
can find that the icon and background image in the upper left corner can be directly loaded.

Guess you like

Origin blog.csdn.net/weixin_46463341/article/details/125831815