Category Archives: Eclipse RCP

My posts on Eclipse RCP development, Eclipse IDE tips …

Eclipse RCP and P2 Headless Update on Startup

I am no more working on Eclipse RCP … since few years now! And this seems not working on recent versions of Eclipse RCP platform (> 4.x) …

Please refer to a very good reference for that Vogella Eclipse RCP articles

This post is neither a tutorial on how to build Eclipse RCP applications nor how to create Eclipse RCP plugins and features, it is a tutorial on how to make and configure an Eclipse RCP application check for updates on startup.


  • Eclipse 3.7 platform
  • Java 6

Basic example project layout

The plugin project

Add the following dependencies to your plugin

  • org.eclipse.equinox.p2.core
  • org.eclipse.equinox.p2.operations
  • org.eclipse.equinox.p2.repository
  • org.eclipse.equinox.p2.metadata

plugin dependencies

Copy the following classes to your plugin src folder

Override the postWindowOpen method of your ApplicationWorkbenchWindowAdvisor class and add in the following code

public void postWindowOpen() {
    BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext();
    ServiceReference<IProvisioningAgent> serviceReference =   bundleContext.getServiceReference(IProvisioningAgent.class);
    IProvisioningAgent agent = bundleContext.getService(serviceReference);
    if (agent == null) {
        System.out.println(">> no agent loaded!");
    // Adding the repositories to explore
    if (! P2Util.addRepository(agent, "http://localhost/p2/repository")) {
        System.out.println(">> could no add repostory!");
    // scheduling job for updates
    UpdateJob updateJob = new UpdateJob(agent);

The feature project

Declare your startup plugin into your feature and add in the following plugins

  • com.ichir.projects.p2update.plugin1 (the plugin we’ve created earlier)
  • org.eclipse.equinox.ds
  • org.eclipse.equinox.p2.core
  • org.eclipse.equinox.p2.director
  • org.eclipse.equinox.p2.engine
  • org.eclipse.equinox.p2.metadata
  • org.eclipse.equinox.p2.metadata.repository
  • org.eclipse.equinox.p2.publisher
  • org.eclipse.equinox.p2.publisher.eclipse
  • org.eclipse.equinox.p2.repository
  • org.eclipse.equinox.simpleconfigurator
  • org.eclipse.osgi
  • org.eclipse.ui.forms
  • org.eclipse.swt.win32.win32.x86

The org.eclipse.swt.win32.win32.x86 plugin depends of course on your platform.

feature dependencies

The .product configuration file

Make your product configuration depends on feature and add in the following features

  • org.eclipse.rcp
  • org.eclipse.equinox.p2.rcp.feature
  • com.ichir.projects.p2update.feature1 (the feature we’ve created earlier)

P2 Product dependencies

Specify the following starting levels in your product file

Product start configuration


When building Eclipse RCP with auto update features, versioning plugins, features and product is a major part! Each time you want to publish an update on a plugin, its version must be augmented, and so its containing feature and the product file. For simplicity, we can add the “.qualifier” to all our versions to automatically augment the version numbers each build is made.

Exporting application, generating the P2 repository and testing

  1. From the .product file, export the application with caution to check “Generate metadata repository” option. This will generate the executable application aside with a repository folder. Just ignore that repository.
  2. Make any modification to your UI and re-export the application to another folder. This time ignore the generated application and copy the generated repository to your HTTP web server (remember that we added “http://localhost/p2/repository&#8221; as an update repository in ApplicationWorkbenchWindowAdvisor)
  3. Once your application restarted, you should be prompted for an update!

That’s done! Enjoy!

To complete

To complete


Put log4j within slf4j in your Eclipse RCP application

If you want to add log4j feature to your eclipse RCP application, the way you used to in your Java programs, it is quite easy !

  • take the ready to use plugin and import it onto your workspace


  • follow the steps below to create a new one from scratch

Note that in this post, we use slf4j API for log4j binding.

From scratch

1. Create a bundle for log4j logging functionality, say “com.ichir.eclipse.logger”

If you use the eclipse RCP “New plugin project” wizard, answer “No” to “Would you like to create a rich client application?” and do not check “this plugin will make contributions to the UI” !

2. Create a “lib” folder in your plugin, download (download adequate versions) and copy the “slf4j-api”, “slf4j-log4j” and “log4j” libraries in it. Add these libraries to your build path.

3. Create a “LoggerFactory” class, that instantiates “ILogger” instances on demand and an “Slf4jLogger” delegate class.

Only the “LoggerFactory” class and the “ILogger” interface are to be exported in the plugin. Let “Slf4Logger” should remain hidden to other plugins, as it is just an “ILogger” implementation.

See the downloads section below for sample downloads of these classes sources.

4. Configuration

Log4j logging configuration is generally made through the file. Create such a file (or copy the one provided here) to your

  • “[ECLIPSE_INSALLATION]/configuration/” folder for use within eclipse
  • “[ECLIPSE_RCP_APPLICATION_BUILD]/configuration/” folder for use within your application build

Note that in the LoggerFactory class, this file is configured and loaded from that “configuration” folder of the application runtime instance. (see the LoggerFactory#configure() method). You can of course change this configuration to fit your needs.

5. That’s it! you are done with it!

In order to use this new plugin and begin “log4j” logging, just add the “logger” plugin created earlier to your plugin dependencies and insert this into your Eclipse RCP code

   private static final ILogger LOGGER = LoggerFactory.getLogger(MyClass.class);
   // my code here ...
   LOGGER.debug(">> my debug message");
   // my code here ...
   try {
      // some code
   } catch (Exception e) {
      LOGGER.error("my error message", e);

You’ll find your logs and log file in the “logs” subfolder of your application (or in your eclipse installation folder), as configured in the “” file.