Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to execute an external program from a plugin
How to execute an external program from a plugin [message #332602] Thu, 30 October 2008 15:47 Go to next message
Eclipse UserFriend
Originally posted by: mam05eux.studserv.uni-leipzig.de

Hello,

i´ve built a plugin that calls an external c#-Program to import some
things using the .Net-Framework.
Ok, during the development of the plugin everything works fine (The
program "*.exe" lies in a subfolder named "temp" of the project) because
the plugin is loaded from the project, so it has a real filepath which I
get using the getInstallUri-Method.

Now my problem: When I export the plugin as a jar the exe cannot be
launched because the file lies within the jar.
So is there any possibility to execute the program at this location or
if not, how can i export a plugin as a directory so that eclipse is able
to load the plugin like a jar (I just tried to extract the contents of
the exportet jar and add the directory to the eclipse-plugin folder but
as I´ve expected eclipse didn´t load the plugin).

Thanks for the moment!
Re: How to execute an external program from a plugin [message #332604 is a reply to message #332602] Thu, 30 October 2008 17:14 Go to previous messageGo to next message
Andrew Niefer is currently offline Andrew NieferFriend
Messages: 990
Registered: July 2009
Senior Member
FileLocator#find(Bundle bundle, IPath path, Map override)
will return a URL for the entry in your bundle.
Then
FileLocator.toFileURL(URL)
will extract the entry to a cache (normally under the
configuration/org.eclipse.osgi directory) and return the URL to the
location on disk.

If you have an Activator for your bundle, you can get your Bundle object
from the BundleContext, otherwise you could use Platform#getBundle

The FileLocator class is in org.eclipse.equinox.common

-Andrew

Stanley Hillner wrote:
> Hello,
>
> i´ve built a plugin that calls an external c#-Program to import some
> things using the .Net-Framework.
> Ok, during the development of the plugin everything works fine (The
> program "*.exe" lies in a subfolder named "temp" of the project) because
> the plugin is loaded from the project, so it has a real filepath which I
> get using the getInstallUri-Method.
>
> Now my problem: When I export the plugin as a jar the exe cannot be
> launched because the file lies within the jar.
> So is there any possibility to execute the program at this location or
> if not, how can i export a plugin as a directory so that eclipse is able
> to load the plugin like a jar (I just tried to extract the contents of
> the exportet jar and add the directory to the eclipse-plugin folder but
> as I´ve expected eclipse didn´t load the plugin).
>
> Thanks for the moment!
Re: How to execute an external program from a plugin [message #332609 is a reply to message #332604] Fri, 31 October 2008 06:19 Go to previous messageGo to next message
Remy Suen is currently offline Remy SuenFriend
Messages: 462
Registered: July 2009
Senior Member
Andrew Niefer wrote:
>
> FileLocator#find(Bundle bundle, IPath path, Map override)
> will return a URL for the entry in your bundle.
> Then
> FileLocator.toFileURL(URL)
> will extract the entry to a cache (normally under the
> configuration/org.eclipse.osgi directory) and return the URL to the
> location on disk.

Andrew, how long is this cache alive for? Will the file be deleted
automagically or...?

> Stanley Hillner wrote:
>> if not, how can i export a plugin as a directory so that eclipse is
>> able to load the plugin like a jar (I just tried to extract the
>> contents of the exportet jar and add the directory to the
>> eclipse-plugin folder but as I´ve expected eclipse didn´t load the
>> plugin).

There should be a way to export as a directory through the regular
export wizard, I've done it before (and continue to do it on occasions
when I need to update my application). I'm not sure how to do it through
pdebuild though.

Rem
Re: How to execute an external program from a plugin [message #332613 is a reply to message #332609] Fri, 31 October 2008 14:55 Go to previous messageGo to next message
Andrew Niefer is currently offline Andrew NieferFriend
Messages: 990
Registered: July 2009
Senior Member
Each bundle gets its own cache space. It should be cleaned up if the
bundle gets uninstalled, but otherwise I think it stays unless someone
runs with -clean.

In a headless build the shape of the built plugin depends on what the
containing feature says for the "unpack" attribute on the plug-in entry.
If not specified, the default is "true", which results in a folder.

If you are running productBuild.xml with a .product, and the container
feature is generated for you, then we guess, which is based on whether
or not the Bundle-Classpath has a '.' on it.

-Andrew

Remy Chi Jian Suen wrote:
> Andrew Niefer wrote:
>>
>> FileLocator#find(Bundle bundle, IPath path, Map override)
>> will return a URL for the entry in your bundle.
>> Then
>> FileLocator.toFileURL(URL)
>> will extract the entry to a cache (normally under the
>> configuration/org.eclipse.osgi directory) and return the URL to the
>> location on disk.
>
> Andrew, how long is this cache alive for? Will the file be deleted
> automagically or...?
>
> > Stanley Hillner wrote:
> >> if not, how can i export a plugin as a directory so that eclipse is
> >> able to load the plugin like a jar (I just tried to extract the
> >> contents of the exportet jar and add the directory to the
> >> eclipse-plugin folder but as I´ve expected eclipse didn´t load the
> >> plugin).
>
> There should be a way to export as a directory through the regular
> export wizard, I've done it before (and continue to do it on occasions
> when I need to update my application). I'm not sure how to do it through
> pdebuild though.
>
> Rem
Re: How to execute an external program from a plugin [message #332704 is a reply to message #332613] Thu, 06 November 2008 09:04 Go to previous message
Eclipse UserFriend
Originally posted by: mam05eux.studserv.uni-leipzig.de

Thanks for your replies.

I´m sorry that I wasn´t able to answer earlier but there was too much to
do at other projects.
So this tip worked fine, thanks a lot!

Stanley

Andrew Niefer schrieb:
> Each bundle gets its own cache space. It should be cleaned up if the
> bundle gets uninstalled, but otherwise I think it stays unless someone
> runs with -clean.
>
> In a headless build the shape of the built plugin depends on what the
> containing feature says for the "unpack" attribute on the plug-in entry.
> If not specified, the default is "true", which results in a folder.
>
> If you are running productBuild.xml with a .product, and the container
> feature is generated for you, then we guess, which is based on whether
> or not the Bundle-Classpath has a '.' on it.
>
> -Andrew
>
> Remy Chi Jian Suen wrote:
>> Andrew Niefer wrote:
>>>
>>> FileLocator#find(Bundle bundle, IPath path, Map override)
>>> will return a URL for the entry in your bundle.
>>> Then
>>> FileLocator.toFileURL(URL)
>>> will extract the entry to a cache (normally under the
>>> configuration/org.eclipse.osgi directory) and return the URL to the
>>> location on disk.
>>
>> Andrew, how long is this cache alive for? Will the file be deleted
>> automagically or...?
>>
>> > Stanley Hillner wrote:
>> >> if not, how can i export a plugin as a directory so that eclipse is
>> >> able to load the plugin like a jar (I just tried to extract the
>> >> contents of the exportet jar and add the directory to the
>> >> eclipse-plugin folder but as I´ve expected eclipse didn´t load the
>> >> plugin).
>>
>> There should be a way to export as a directory through the regular
>> export wizard, I've done it before (and continue to do it on occasions
>> when I need to update my application). I'm not sure how to do it
>> through pdebuild though.
>>
>> Rem
Previous Topic:Synchronize view not showing files in conflict mode after update
Next Topic:Multiline TreeViewer
Goto Forum:
  


Current Time: Wed Jul 17 18:27:17 GMT 2024

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

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

Back to the top