Skip to main content



      Home
Home » Newcomers » Newcomers » Best practice? Add resources to eclipse plugin
Best practice? Add resources to eclipse plugin [message #271889] Wed, 01 July 2009 06:19 Go to next message
Eclipse UserFriend
Hi,

I have a problem to open a file in a eclipse plugin application.

I create following structure:


src/main/java/
mwoelm.pmc.ModelCompilation.java
...
src/main/resources/
template/aspect.tpl

I try to open the aspect.tpl file in the ModelCompilation class:

URL url = this.getClass().getResource("/template/aspect.tpl");
System.out.println(url);
FileReader fr = new FileReader(new File(url.getPath()));
...

This works, if I start this application standalone java application, but
if I start the plugin in a workbench I get:

bundleresource://406.fwk22048196/template/aspect.tpl
java.io.FileNotFoundException: /template/aspect.tpl (No such file or
directory)


Any advice?

Best regards,
miwoe
Re: Best practice? Add resources to eclipse plugin [message #271891 is a reply to message #271889] Wed, 01 July 2009 06:48 Go to previous messageGo to next message
Eclipse UserFriend
Michael,

Comments below.

Michael Wölm wrote:
> Hi,
>
> I have a problem to open a file in a eclipse plugin application.
>
> I create following structure:
>
>
> src/main/java/
> mwoelm.pmc.ModelCompilation.java
> ...
> src/main/resources/
> template/aspect.tpl
>
> I try to open the aspect.tpl file in the ModelCompilation class:
>
> URL url = this.getClass().getResource("/template/aspect.tpl");
> System.out.println(url);
> FileReader fr = new FileReader(new File(url.getPath()));
> ..
>
> This works, if I start this application standalone java application,
> but if I start the plugin in a workbench I get:
>
> bundleresource://406.fwk22048196/template/aspect.tpl
> java.io.FileNotFoundException: /template/aspect.tpl (No such file or
> directory)
Is this resources folder on the runtime classpath for the bundle?
Putting it in the same folder as ModelCompilation and using
getResource("aspect.tpl") would seem simpler.
>
>
> Any advice?
>
> Best regards,
> miwoe
>
Re: Best practice? Add resources to eclipse plugin [message #271893 is a reply to message #271889] Wed, 01 July 2009 07:46 Go to previous messageGo to next message
Eclipse UserFriend
After searching for hours, I think I have found a solution.
Perhaps not a best practice.

It can be read here:

http://codeache.blogspot.com/2007/05/loading-files-with-rcp. html

Regards,
Michael
Re: Best practice? Add resources to eclipse plugin [message #271895 is a reply to message #271891] Wed, 01 July 2009 07:58 Go to previous messageGo to next message
Eclipse UserFriend
I have checked this, but it throws almost the same exception:

java.io.FileNotFoundException: /mwoelm/pmc/generatedAspect.tpl (No such
file or directory)

However, found a solution:
http://codeache.blogspot.com/2007/05/loading-files-with-rcp. html


But I am not happy about the fact that I need to search for the file,
although I know at least the relative path.
Re: Best practice? Add resources to eclipse plugin [message #271909 is a reply to message #271893] Wed, 01 July 2009 11:39 Go to previous message
Eclipse UserFriend
Michael Wölm wrote:

> After searching for hours, I think I have found a solution.
> Perhaps not a best practice.

> It can be read here:

> http://codeache.blogspot.com/2007/05/loading-files-with-rcp. html

> Regards,
> Michael

Michael:

Thanks for this - I think it will become useful when I start coding in
eclipse. I have, I think, found the entry that I needed to be able to
install RCP and other components of eclipse.

I think in the course of their research, David and Lars have uncovered a
problem with the RCP links, and that they are looking into these.

Regards,
Flavelle
Previous Topic:Empty Preferences Dialog
Next Topic:Galileo Installation
Goto Forum:
  


Current Time: Sat Jun 07 23:21:05 EDT 2025

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

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

Back to the top