Hello..

I created a executable jar file for my java application..
but there's a problem that the images are not being displayed in application eventhough
i included images in jar file along with classes.

How to make them displayed from the jar file only instead of accessing them
from any folder or something..

By using getResourceAsStream rather than File operations as the images within the jarfile are no longer "files" in and of themselves and so cannot be accessed through "File" classes (such as File, FileInputStream, FileChannel, or the Image operations that take a file as a parameter).

By using getResourceAsStream rather than File operations as the images within the jarfile are no longer "files" in and of themselves and so cannot be accessed through "File" classes (such as File, FileInputStream, FileChannel, or the Image operations that take a file as a parameter).

so can u just show how to load an image from the jar file..

Show how you are loading images now and I will suggest a way of changing it. But really, look at the API docs for that method and for the class with which you are loading the images and try something.

Edited 5 Years Ago by masijade: n/a

This article has been dead for over six months. Start a new discussion instead.