Referencing an image in my projects jar file

I don't seem to be able to reference an image in my netbeans project. Here is what it looks like in netbeans:

http://picasaweb.google.com/cendrizzi/JavaStuff/photo#5068570476760118770

Here is my code that I'm using to reference one of these images:

URL imageURL = this.getClass().getResource("images/clock.png");

Image image = Toolkit.getDefaultToolkit().getImage(imageURL);

I'm really new at this so I'm not sure what I'm doing wrong. I've tried "images/clock.png" as shown and just "clock.png" . Neither seems to find it there.

Thanks!

[612 byte] By [nehalema] at [2007-11-27 5:32:10]
# 1
Is this in your jar file?(from your old thread -->) http://forum.java.sun.com/thread.jspa?threadID=5176706
kevjavaa at 2007-7-12 14:58:01 > top of Java-index,Java Essentials,Java Programming...
# 2

Since you provided a relative URL to the getResource method, you need to know that it is relative to the package of the class that called the method. So if your class was in package org.bananarama, you would be looking for the path /org/bananarama/images/clock.png in your jar file.

If you wanted to look for the absolute path /images/clock.png then specify that absolute path.

DrClapa at 2007-7-12 14:58:01 > top of Java-index,Java Essentials,Java Programming...
# 3
That did it. I copied the images down into the package with my classed and referenced it /package_name/clock.png did it. Thanks guys!
nehalema at 2007-7-12 14:58:01 > top of Java-index,Java Essentials,Java Programming...