Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » relative path inside a plugin
relative path inside a plugin [message #326471] Thu, 20 March 2008 08:49 Go to next message
Eclipse UserFriend
Originally posted by: zhuj.in.tum.de

Hi everyone,

this is actually a repost from the eclipse.pde. sorry for this, but I'm
really eager to get the answer.


I have a question about "how to specify a relative path for a file in the
plugin".

the situation looks like the following:
I have a ontology file ont.owl in my Plugin P1. Now in some class of P1,
in order to access ont.owl, I used absolute paths. But this Path is
different on others' machine. And absolute path became problematic on
differnt machines.


So my question: How should I access this ont.owl inside P1, using a
relative path.
any idea how to achieve this?

best regards!
Jinhui
Re: relative path inside a plugin [message #326473 is a reply to message #326471] Thu, 20 March 2008 09:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: zhuj.in.tum.de

i got it:

this.getClass().getResourceAsStream("../ont.owl");
Re: relative path inside a plugin [message #326502 is a reply to message #326471] Fri, 21 March 2008 03:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: massimiliano.fanciulli.intecs.it

Hi Jinhui,

you can use the following piece of code:

Bundle plugin;
URL entry;
InputStream stream;

plugin=Platform.getBundle(<PLUGIN_ID>);
entry=plugin.getEntry(<RELATIVE_PATH_TO_FILE>);

stream=url.openStream();

I hope this could help you.
Regards,
Massimiliano Fanciulli

Jinhui wrote:
> Hi everyone,
> this is actually a repost from the eclipse.pde. sorry for this, but I'm
> really eager to get the answer.
>
>
> I have a question about "how to specify a relative path for a file in
> the plugin".
>
> the situation looks like the following:
> I have a ontology file ont.owl in my Plugin P1. Now in some class of P1,
> in order to access ont.owl, I used absolute paths. But this Path is
> different on others' machine. And absolute path became problematic on
> differnt machines.
>
>
> So my question: How should I access this ont.owl inside P1, using a
> relative path.
> any idea how to achieve this?
>
> best regards!
> Jinhui
>
Re: relative path inside a plugin [message #326504 is a reply to message #326502] Fri, 21 March 2008 04:00 Go to previous message
Eclipse UserFriend
Originally posted by: massimiliano.fanciulli.intecs.it

Ops, i have made a mistake. Below the correct statement:

Massimiliano Fanciulli wrote:
> Hi Jinhui,
>
> you can use the following piece of code:
>
> Bundle plugin;
> URL entry;
> InputStream stream;
>
> plugin=Platform.getBundle(<PLUGIN_ID>);
> entry=plugin.getEntry(<RELATIVE_PATH_TO_FILE>);
>
> stream=url.openStream();
>

stream=entry.openStream();


Regards,
Massimiliano

> I hope this could help you.
> Regards,
> Massimiliano Fanciulli
>
> Jinhui wrote:
>> Hi everyone,
>> this is actually a repost from the eclipse.pde. sorry for this, but
>> I'm really eager to get the answer.
>>
>>
>> I have a question about "how to specify a relative path for a file in
>> the plugin".
>>
>> the situation looks like the following:
>> I have a ontology file ont.owl in my Plugin P1. Now in some class of
>> P1, in order to access ont.owl, I used absolute paths. But this Path
>> is different on others' machine. And absolute path became problematic
>> on differnt machines.
>>
>>
>> So my question: How should I access this ont.owl inside P1, using a
>> relative path.
>> any idea how to achieve this?
>>
>> best regards!
>> Jinhui
>>
Previous Topic:Handler, activeWhen, PropertyTester and multiple selections
Next Topic:"org.eclipse.ui.examples.navigator"'s code not executing at all, what's wrong?
Goto Forum:
  


Current Time: Wed Apr 16 09:04:43 EDT 2025

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

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

Back to the top