Well... just print out the url and check if it makes sense.
Let's say you have this lines of code:
1 2
| keyboardImagePath = (new Object()).getClass().getResource("/gfx/keyboard.gif"); System.out.println("path: "+keyboardImagePath); |
And the jar itself is in "C:\dls\java\q3tools\scancode" and the jar is called "KeyMatrix.jar".
The output is then:
path: jar:file:/C:/dls/java/q3tools/scancode/KeyMatrix.jar!/gfx/keyboard.gif
And that works perfectly. The jar is really there and the file "keyboard.gif" is really inside the jar inside a sub directory called "gfx".
So just print the path and take a close look. It should start with "jar:file:/", then the
full path to the jar, then an exclamation mark and finally the relative path to the file you are looking for.