eclipse打包后图片无法显示的问题

eclipse打包后图片无法显示的问题
工程下有一个文件夹res存放图片,在eclipse下可以正常加载图片,打包后程序可以运行,但无法加载图片,查看jar包res也是有被打包进去的。
谢谢了!
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ImageTest extends JFrame
{
private static final long serialVersionUID = 1L;
public ImageTest()
{
setSize(800, 600);
setLocation(100, 100);
Icon iconObj = new ImageIcon("res\\default.gif");
JLabel jl = new JLabel(iconObj);
getContentPane().add(jl);
setVisible(true);
}
public static void main(String[] args)
{
new ImageTest();
}
}
问题是如何打包了也能正常使用
我记得好像应该把res文件夹放在jar所在的同一个目录下,就是不用打包进去,试试看
← 上一篇: 下一篇: →