Restarting an e4 application with the intial workbench.e4xmi

e4 applications by default remember the state when getting shutdown and restore that state on the next restart. This is the behavior most people expect from an application but there are situations people would like to reset the application into its original state or maybe the developer wants that e.g. after having installed/uninstalled certain new bundles.

Unfortunately the workbench currently does not provide a way restart and clear the current state. So I’ve implemented a small library you can make use of in your e4 applications.

There are 2 parts:

  1. a service called RestartService which has a method restart(boolean)
  2. a Lifecycle-Addon you can reuse or copy the code from min to yours

Useage is very simple e.g. in your handler:

import org.eclipse.e4.core.di.annotations.Execute;


public class RestartHandler {
  public void restart(RestartService service) {

and to enable the addon you make your plugin.xml look like this:

<?xml version="1.0" encoding="UTF-8"?>

If you want to make use of it you can find the p2-repo at or if you prefer the source it is hosted at the github account of at

This entry was posted in e4. Bookmark the permalink.

7 Responses to Restarting an e4 application with the intial workbench.e4xmi

  1. Dieter Rehbein says:

    Here is another solution for the same problem (clear persisted state, if a new application version is installed):

    I’ve implemented a subclass of E4Application, which overrides the method

    public Object start(final IApplicationContext applicationContext) throws Exception;
    if (isVersionChanged()) {
    System.setProperty(“clearPersistedState”, “true”);
    return super.start(applicationContext);

    The method isVersionChanged() returns true, if a new version of the application is detected (it is not part of E4Application, has to be implemented by yourself).

    Then I’ve added an extension to the plugin.xml of the application for the extension point org.eclipse.core.runtime.applications, which adds this subclass of E4Application to the list of available applications.

    In the application product definition (tab Overview) select your application-class.

    => Now the persisted state is cleared everytime a new version of the application installed

    • Tom Schindl says:

      Right that works but E4Application is not public API bottom line is that the core framework should provide this feature built-in

  2. Pingback: Add p2 update functionality to an Eclipse 4 application - Eclipse RCP Cookbook - codecentric Blog

  3. Pingback: Add p2 update functionality to an e(fx)clipse application – Eclipse RCP Cookbook - codecentric Blog

  4. Tried to use “” from p2-repo at for e4 RCP development with Eclipse Neon.1a Release (4.6.1). Plugin not visible in any view within Eclipse for RCP Developers? May be because it is not signed? (I have no other idea after several tries.)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.