Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » why can't Image be found by using "new Image(path)" in rcp?
why can't Image be found by using "new Image(path)" in rcp? [message #467140] Sun, 29 April 2007 01:20 Go to next message
Eclipse UserFriend
Originally posted by: wangyang227.21cn.com

why can't Image be found by using "new Image(path)" in rcp?
It can be found when running as a single swt class.
e.g there is a picture in workspace/rcp_project/icons/ff.gif
I use new Image("icons/ff.gif") to load it, it can be found when runned as a single swtclass,but cannot be found when runned
as a RCP
who can help me? thanks
Re: why can't Image be found by using "new Image(path)" in rcp? [message #467146 is a reply to message #467140] Sun, 29 April 2007 08:50 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Check build.properties -- is the 'icons' folder present in the bin.includes line?

Alex.
Re: why can't Image be found by using "new Image(path)" in rcp? [message #467151 is a reply to message #467146] Sun, 29 April 2007 12:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wangyang227.21cn.com

it already has "icons/" in bin.includes
Re: why can't Image be found by using "new Image(path)" in rcp? [message #467153 is a reply to message #467151] Sun, 29 April 2007 18:07 Go to previous message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Does putting / on the front of the string help?

You could also try using new Image(getClass().getResourceAsStream("/icons"), but then your icons/ would have to be on the classpath (e.g. copied into a bin/ location).

The problem is that the location of the file can't be guaranteed when loaded as a File name, so what you have to do is load the bytes via either getClass().getResourceAsStream(), or use bundle.getEntry() to load the resource from the bundle itself. Both have their problems ... the former is easier to code, but you need to make sure they're on the classpath (and in dev mode in Eclipse, that's not usually the case), whilst the latter will just search the Bundle, but you have to acquire the bundle context in order to get the bundle itself, which is sometimes more tricky.

Unfortunately, manipulating resources in Eclipse is unnecessarily difficult owing to how PDE treats the build resources. If instead of having the notion of classes living in one place and resources mounted at the root, then you wouldn't have all this difficulty; but that's not likely to change any time soon.

Alex.
Previous Topic:Resize views and editors inside perspective
Next Topic:Request about propertyView
Goto Forum:
  


Current Time: Thu Apr 25 07:28:26 GMT 2024

Powered by FUDForum. Page generated in 0.02954 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top