Eclipse exported Runnable JAR not showing images

后端 未结 8 1553
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 16:46

My images will not load when running a JAR file exported from Eclipse.

I have the images in a resources class package. I\'ve tried a images source folder as well wit

8条回答
  •  名媛妹妹
    2020-11-22 17:21

    Unless you have to have you files in the jar, this is probably the simplest way of doing it:

    header = ImageIO.read(new File("./resources/header.jpeg"));

    header has to be an Image/BufferedImage. This goes to the folder that the runnable jar is within and looks for a folder called resources. http://i.stack.imgur.com/x8xtO.png

提交回复
热议问题