Image in JAR not found/used

I have a gif image that is called by a JLabel:

JPanel cp = new JPanel(new GridLayout(0,2));
cp.add(new JLabel(new ImageIcon("test.gif")));

I produced a jar by using this command: "jar cvfm MyApp.jar manifest.txt *.class test.gif"

The jar is correctly created and the image is shown if the jar is run in a directory that contains "test.gif" (the contents of the directory are MyApp.jar and test.gif). If the gif isn't in the same directory, the image won't show. What am I doing wrong?

Thank you! :)
mortiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

suprapto45Commented:
Hi,

I am not pretty sure but will this solution from CEHJ help you?

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20871805.html

Regards
Dave
CEHJCommented:
Yes that should do it ;-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mortiAuthor Commented:
My solution was similar:

cp.add(new JLabel(new ImageIcon( this.getClass().getResource("/test.gif")) ));
CEHJCommented:
:-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.