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
8,45910 gold badges50 silver badges80 bronze badges
asked Mar 8, 2015 at 11:31
4
  • 2
    Look at the org.eclipse.ui.startup extension point Commented Mar 8, 2015 at 12:01
  • Simply Adding your piece of code in activator .start method Would also achieve that. Commented Mar 8, 2015 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. Commented Mar 8, 2015 at 14:59
  • Stephan Herrmann- Hmmm okie. I understand completely now.. upvoted Greg answer too:-) Commented Mar 8, 2015 at 18:47

1 Answer 1

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,6478 gold badges36 silver badges47 bronze badges
answered Mar 8, 2015 at 15:43
Sign up to request clarification or add additional context in comments.

2 Comments

What if I'm on a pure E4 plugin (not application) which has no access to IStartup?
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.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.