
Signature
Thomas A. Russ, USC/Information Sciences Institute
>> and i'm already providing the correct path (just as I have already
>> stated in the original mesg) where they can be found *within* the jar
[quoted text clipped - 4 lines]
> jar and not in a subdirectory of the place in the jar where the class
> file is in which you make the getClass() call.
I don't think I can make it any clearer where the images are located
beyond what I've already said (and short of posting a screenshot of the
contents when viewed in winrar). I have a bunch of class files and at
the SAME level as the class files in the jar file is an images directory
and within that directory is the icon files. It is the same structure as
what is used in the Sun tutorials.
> If you look at the getResource documentation, is says that if the name
> doesn't start with "/", then "the package name is prepended to the
> resource name." That means it is looking for an "images"directory
> starting at the point in your source tree where the ".class" file is
> located.
Why would the name start with a "/"? The folder is images, plain and
simple. I don't see how a / could be introduced which is why the doc
didn't make a bit of sense. From what I can tell there is no "/" but the
package name shouldn't be prepended because I'm not using a package,
which is another reason the doc didn't help.
So if it is looking where you say it should be then it should be finding
my images directory because it is at the same level in the jar as the
class file is located.
> Have you tried it with a leading "/" character?
Yes, I've tried with //, /, \, \\, and all those both at the front of
the path and in between the images folder name and the actual icon file
name such as //images//icon.gif. None of those combinations work.
> Have you tried printing out the URL that getResource returns?
yes
What does
> it look like?
It was null as I posted in another message when someone asked for the
specific exception that was generated. It was a null pointer exception
which makes sense since the getResource method returns null.
It should look like the correct path in the jar file to
> where the image is located. Does it?
No, I'm guessing that if it did I wouldn't have a problem.
Thomas A. Russ - 25 Jan 2006 02:35 GMT
> > Have you tried printing out the URL that getResource returns?
> yes
[quoted text clipped - 3 lines]
> specific exception that was generated. It was a null pointer exception
> which makes sense since the getResource method returns null.
OK. I guess it's time to look further back up the chain of calls. What
does getClass() return? What about getClassLoader()? This is where the
lookup of resources happens. If that returns null (meaning the
bootstrap loader is being used), then I'm not sure where to go from
there.
If you get a class loader, can if find your class using the findClass
method?
> It should look like the correct path in the jar file to
> > where the image is located. Does it?
> No, I'm guessing that if it did I wouldn't have a problem.

Signature
Thomas A. Russ, USC/Information Sciences Institute
Brandon McCombs - 09 Feb 2006 00:29 GMT
>>> Have you tried printing out the URL that getResource returns?
>> yes
[quoted text clipped - 16 lines]
>>> where the image is located. Does it?
>> No, I'm guessing that if it did I wouldn't have a problem.
Not sure if this changes any of your post but I had another post near
the same time as the one you responded to above stating I had fixed the
problem but I found out that I hadn't really done so. I fixed the icons
loading from within a jar file but after going back to Eclipse I found
that the icons *stopped* loading in there so I fixed it one place and
broke it in the original place.
I got it to work in the jar file by putting this in the code:
setIcon(new ImageIcon("LDAPMgr/images/domIcon.gif"));
It probably has something to do with the classpath but I just haven't
taken the time yet to go back and experiment.
I fixed it finally by using the following:
setIcon(new ImageIcon("LDAPMgr/images/domIcon.gif"));
I had to get rid of the getResource() as you can tell and prepend the
main class name to the beginning of the path.
At one point I had:
setIcon(new ImageIcon(LDAPMgr.class.getResource("images\\domIcon.gif")));
but even that didn't work despite the same class file (LDAPMgr) being
specified.
thanks