Hi all, I am Chaitanya, I developed a swing application and created a jar file to launch the application. The jar consists image files and class files. When i try to run the jar file the images aren't loading in the application. When I try to run the same jar with the images paced in the same directory of the jar, then my application is loading the images.
What is the problem here? I don't want to place the images separately. I want them in the jar only.
Can anyone tell me how to do this? Thank you all in advance.
How are you trying to load the files? You can't use the File and FileInputStream classes (since the images are not files). But the jar file is in the classpath, so you can use something like getClass().getResourceAsStream(...).
Hi Mr. Dittmer, I am using JTextPane to show the images. There is a html file in which I wrote all support information of my application. Using setPage(url) method of JTextPane class I am displaying the html file.
I choose this method because it saved my time in formatting the text and representing.
Paul Clapham wrote:Not really. Ulf Dittmer asked you a question:
Ulf Dittmer wrote:How are you trying to load the files?
You completely ignored the question and told us something else:
chaitanya karthikk wrote:I am using JTextPane to show the images.
So if you aren't going to answer questions which were meant to find out more about your problem, it looks like you will have to make do with the other suggestions which Ulf made.
Hi Mr. Paul, thats what I said,. Mr. Dittmer said to use getClass().getResourceAsStream().
I wrote a HTML code which uses the image files. I wrote a java program which loads the HTML file. My program is loading the HTML file, the html file is not loading the images.
Joined: Mar 22, 2005
HTML doesn't know the first thing about jar files, so that approach is not going to work.