|
-
Oct 29th, 2009, 01:45 PM
#1
Thread Starter
New Member
Read images inside jar-file
Hello
I'm making a program and I want to put the program in a JAR-file. But when I put it in one, the images aren't found. I did try many things, such as the getClass().getSourceAsStream(Filename), but no one works. Can anyone help me, please?
this is the code(I show one example, the others are similar):
The main-class App.class calls a method in the class Image
HTML Code:
saveIcon = new ImageIcon((Image)ImageIO.read(new BufferedInputStream(this.getClass().getResourceAsStream("/save.png"))));
This is the file-content:
App.jar
App.class
Image.class
save.png
Thanks in advance
Grimling
-
Oct 29th, 2009, 02:24 PM
#2
Re: Read images inside jar-file
This seems to have a way to handle it.
But why are you putting it into the jar file? Why not use an installer to place the files in an appropriate directory?
-
Oct 29th, 2009, 02:27 PM
#3
Thread Starter
New Member
Re: Read images inside jar-file
Thanks, I will try it. I have heard of installers, but I don't understand it very well. If I use an installer, is it than platform-independent? And is there a way to start the program by simple double-click on it? If I distribute the program, users don't want to open the commandline.
mvg
Grimling
Last edited by Grimling; Oct 29th, 2009 at 02:36 PM.
-
Oct 30th, 2009, 06:38 AM
#4
Re: Read images inside jar-file
Well you'll have to associate the jar files with java. Otherwise they'll open a extraction tool or even Nokia PC Suite. you can always put your command line script in a bat file (and a bash file for Mac and Linux) so users can start your app with a single click
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 31st, 2009, 08:03 AM
#5
Thread Starter
New Member
Re: Read images inside jar-file
Thanks, the program works now when you download it and save it to a hard disk or USB-stick or whatever...But not when it is running from in the browser. There's no advantage by installing it, but, your explication can help me with another project.
Grimling
PS: If you are interested, this is the link to the page where you can download the program, the page is in Dutch, but it's the 'Download'-button 
http://floriskint.000space.com/artikels/FMathApp.php
-
Oct 31st, 2009, 10:04 AM
#6
Re: Read images inside jar-file
If it runs in Explorer it runs in IE. Other browsers usually use explorer to open files for windows. In most Linux distros the mime type is the major factor to opening a file and I think Macs work the same way
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 31st, 2009, 10:09 AM
#7
Thread Starter
New Member
Re: Read images inside jar-file
I tried it with Firefox and Opera. Neither it works in IE.
Grimling
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|