Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Get resource works from within IDE but not after export(Therefore can't deploy application!)
Get resource works from within IDE but not after export [message #683513] Mon, 13 June 2011 22:32 Go to next message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
I have a strange problem trying to read a file as a plug-in resource. The code looks like this:

			final InputStream is = MyClass.class.getResourceAsStream("/myfile.txt");
			try {
				int i = 0;
				while ((i = is.read()) != -1) {
					sb.append((char)i);
				}
				is.close();
			} catch (final IOException ioe) {
				logger.error(ioe.getMessage());
			}


This works fine when I run the application from within Eclipse but fails when I run it after exporting the plug-in's product with a null input stream being returned from the getResourceAsStream() method.

MyClass is not in the plug-in which contains the product I am actually running, it is in a dependent plug-in instead.

Why is it that it can find the file when I run from the IDE but not after exporting? How can I load this resource from within the code?

Thanks,

-sbs
Re: Get resource works from within IDE but not after export [message #683818 is a reply to message #683513] Tue, 14 June 2011 13:25 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Is myfile.txt in the root of the plugin that contains MyClass when that plugin is exported?

A plugin can only see it's own classes/resources, plus exported stuff from other plugins it requires.

PW


Re: Get resource works from within IDE but not after export [message #683866 is a reply to message #683818] Tue, 14 June 2011 14:13 Go to previous messageGo to next message
Thomas Haskes is currently offline Thomas HaskesFriend
Messages: 147
Registered: July 2009
Senior Member
Am 14.06.2011 15:25, schrieb Paul Webster:
> Is myfile.txt in the root of the plugin that contains MyClass when that
> plugin is exported?
>
> A plugin can only see it's own classes/resources, plus exported stuff
> from other plugins it requires.
>
> PW
>
Also, check if myFile.txt is checked on the build.properties page in the
plugin, otherwise the file is not exported.
Re: Get resource works from within IDE but not after export [message #684702 is a reply to message #683866] Thu, 16 June 2011 04:43 Go to previous message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
Thomas Haskes wrote on Tue, 14 June 2011 10:13
Also, check if myFile.txt is checked on the build.properties page in the
plugin, otherwise the file is not exported.


Thanks, that was the cause of the problem.

-sbs
Previous Topic:Updating RCP application using Plugins
Next Topic:Force application to run when window hidden
Goto Forum:
  


Current Time: Sat Sep 21 04:30:35 GMT 2024

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

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

Back to the top