how to test retrieving embedded resource while debugging in eclipse

I am going to embed a file into my jar when i deploy.  I want to debug the applicaiton iin Eclipse while using the code the that retrieves the embedded resourece.  Is there a way in which i can do this? (Eclipse is using the class files).
LVL 5
jjacksnAsked:
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.

 
sciuriwareCommented:
Why shouldn't you just do this; debugging retrieval is no different
from debugging your program.

Or am I missing something?

You should of course have the resource file in the right directory ......

;JOOP!
0
 
sciuriwareCommented:
May be I understand:
you can not debug a .jar unless the source code is available.
The resource file should be besides the class that you use as
a reference for the classloader: that is the place from where you jarred it.
There should be no problem then,
but I advise you to debug classes and after corrections .jar them.
;JOOP!
0

Experts Exchange Solution brought to you by ConnectWise

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
 
CEHJCommented:
URL resource = getClass().getResource("x");
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
jjacksnAuthor Commented:
here is the scenario:

right now, I have all my class files that I am still debugging a developing.  I need to test the resource loading part because there is an expected behavior when the key is not embedded in the jar.  however, the jar that it will be embedded in does not exist yet.  I am still debugging a lot of stuff.  therefore, I want to make this call:

URL resource = getClass().getResource("x"); and have it work and not work in different scenarios.
0
 
sciuriwareCommented:
If you build a .jar from the class file tree (!) with the resources
in the right place it will work.

;JOOP!
0
 
jjacksnAuthor Commented:
I'm trying to do this through the IDE... what would be the steps.  I know I can export the jar, but then I would need to do that for every code change, and i'm going to playing with this for a while so that would be a painfully slow process.  
0
 
CEHJCommented:
You don't need to change code to get the resource. It'll work both in and out of a jar as it works by classpath
0
 
objectsCommented:
have the resource in a source folder in eclipse
and then when you build a jar include that source folder in the jar
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.