File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse JAR Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse JAR Problem" Watch "Eclipse JAR Problem" New topic

Eclipse JAR Problem

Kevin Adu-Sarkodie

Joined: Feb 28, 2011
Posts: 7
Hey Guys,

I got a problem with creating a Executable JAR in Eclipse.
My application uses images and when I try to run the JAR that Eclipse creates it doesn't find the image files.
I keep my images in a separate folder called images along with the src folder and others in the project.
It detects them fine when I run it in Eclipse.
The way I access the images in my Java code is like this:

I have also tried this way:

And neither way works.
I was hoping if anyone can help me, Thanks.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10768

getClass().getResource() is the correct way to access jarred resources.
However you need to supply the name of the resource.
How do you expect blank quotes to work?

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: Eclipse JAR Problem
It's not a secret anymore!