Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where does a class look for resources?

 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all,

What is the location where the class loader searches for resources as in the following usage?

java.net.URL imgURL = getClass().getResource(path);


Thanks,

Colm
 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks..and by resources this can be anything such as other classes, files, images etc?

(For example, I want to use this to locate an image file so I can create an image icon to display on a panel....)



Colm
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You can even use the class files themselves as resource:
 
Colm Dickson
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help and the useful link.

Colm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic