|
-
November 23rd, 2009, 05:30 AM
#1
JAR doesn't work in an other directory
Hi,
I create executable JAR files in Eclipse and manually. The JAR contains the CLASS files and images that I use in my program. It works fine but when I move the JAR in an other directory the images don't get visualized. I opened the JAR to make sure that the image files are in and they are there. What's the problem?
-
November 23rd, 2009, 09:36 AM
#2
Re: JAR doesn't work in an other directory
... what is the structure of your images? Do you have them separated in their own package?
I have my problem where images are not showing up at all. How are you showing them, in code?
Last edited by capitolc; November 23rd, 2009 at 09:44 AM.
-= the best is yet to come =-
-
November 23rd, 2009, 09:47 AM
#3
Re: JAR doesn't work in an other directory
I just have the images alongside the source/class files and show them by means of the default toolkit getImage() method.
-
November 23rd, 2009, 01:00 PM
#4
Re: JAR doesn't work in an other directory
I just moved my jar in different directories and I'm seeing the same thing. Once more, the image only shows when I run it from within Eclipse. Is this the same for you?
Well, someone suggested I use the getResource to obtain the url path of the image. When I did that, I'm getting my image where ever I put the jar file.
Code:
URL urlIMG = getClass().getResource("/dir/filename.jpg");
If you use this in place of .getImage(), your image may show up regardless of location of the jar file. Be sure to import the package "java.net.URL"
-= the best is yet to come =-
-
November 23rd, 2009, 01:06 PM
#5
Re: JAR doesn't work in an other directory
Can I ask what options are you selecting when you create your jar file?
I just want to make sure I am doing it the correct way. I am select the export option under file. From there, I am selecting 'runnable jar'. The launch config is the src/project I'm looking to export. But which are you selecting for your 'library handling'? I'm selecting 'package required libraries' - this only makes sense to me since I don't want to extract or leave out anything. right? what's your method?
-= the best is yet to come =-
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
|