Forum Stats

  • 3,769,837 Users
  • 2,253,027 Discussions
  • 7,875,220 Comments

Discussions

Images(.gif/.jpg) from JAR.

843798
843798 Member Posts: 24,864
Hi,

Is there any way to load images from JAR file?
I am not able to get images to Java application (GUI) from JAR file. If I extract JAR file it is working.

Any help is appreciated.

Rama Reddy.

Comments

  • 794066
    794066 Member Posts: 151
    You want to start with:
    getClass().getResourceAsStream("MyPicture.gif");
    That will read your given filename (from your JAR) as an InputStream. You can read it into an Image or whatever from there. I've only done it with a text-file, so I don't know the particulars about loading an image.

    Michael Bishop
This discussion has been closed.