6

I want to create an Eclipse plugin that automatically runs in the background, as soon as the user opens the Eclipse IDE.

For example, I am building a Java Eclipse plugin that gets the current active file address, but I would like this plugin to always run in the background without user having to run it manually.

How to achieve this?

scopchanov
  • 7,966
  • 10
  • 40
  • 68
Erfan Farhangy
  • 449
  • 2
  • 7
  • 14
  • 2
    Look at the `org.eclipse.ui.startup` extension point – greg-449 Mar 08 '15 at 12:01
  • Simply Adding your piece of code in activator .start method Would also achieve that. – Karthik Rocky Mar 08 '15 at 12:14
  • 3
    @KarthikRocky: no, code in Activator.start() is only invoked when the containing plugin is activated. Due to lazy loading you normally have no control over this. The extension point mentioned by greg-449 serves this purpose. Alternatively, setting the startlevel of a plug-in can be used to force eager activation, but to configure the startlevel is more challenging than providing the said extension. – Stephan Herrmann Mar 08 '15 at 14:59
  • Stephan Herrmann- Hmmm okie. I understand completely now.. upvoted Greg answer too:-) – Karthik Rocky Mar 08 '15 at 18:47

1 Answers1

12

The org.eclipse.ui.startup extension point lets you define a class that is run early during workbench initialization.

The extension point looks something like:

<extension point="org.eclipse.ui.startup">
   <startup class="package.StartupClass"/>
</extension>

the class specified must implement the org.eclipse.ui.IStartup interface.

More details here

Nikolai Shevchenko
  • 7,083
  • 8
  • 33
  • 42
greg-449
  • 109,219
  • 232
  • 102
  • 145
  • What if I'm on a pure E4 plugin (not application) which has no access to IStartup? – LppEdd Apr 13 '22 at 14:10
  • Ok. Debugging the platform (with compatibility layer) I've found that APP_STARTUP_COMPLETE is called just before IStartup implementations. Would be a good addition to the answer! Thanks Greg as always. The only difference is that IStartup is called through a Job, which tracks progress. – LppEdd Apr 13 '22 at 14:31