?
Solved

how to test retrieving embedded resource while debugging in eclipse

Posted on 2006-04-21
11
Medium Priority
?
282 Views
Last Modified: 2008-03-03
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).
0
Comment
Question by:jjacksn
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 16509083
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
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
ID: 16509111
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 16509112
URL resource = getClass().getResource("x");
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Author Comment

by:jjacksn
ID: 16509210
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
 
LVL 24

Expert Comment

by:sciuriware
ID: 16509227
If you build a .jar from the class file tree (!) with the resources
in the right place it will work.

;JOOP!
0
 
LVL 5

Author Comment

by:jjacksn
ID: 16509364
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
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 500 total points
ID: 16509379
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
 
LVL 92

Assisted Solution

by:objects
objects earned 500 total points
ID: 16512278
have the resource in a source folder in eclipse
and then when you build a jar include that source folder in the jar
0
 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 500 total points
ID: 16519939
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question