Java, Eclipse and Web programming Tutorials
Follow me on twitter About Lars Vogel

Eclipse p2 Packaging and Update - Tutorial

Lars Vogel

Version 0.7

18.01.2010

Revision History
Revision 0.1 -0.216.09.2008Lars Vogel
Created Article
Revision 0.325.05.2009Lars Vogel
Updated to Plugins and Eclipse 3.5
Revision 0.414.09.2009Lars Vogel
Minor changes
Revision 0.525.11.2009Lars Vogel
Minor changes
Revision 0.617.12.2009Lars Vogel
started p2 for Eclipse RCP application
Revision 0.718.01.2010Lars Vogel
added required feature for p2 update

Eclipse p2 - Update

This article describes how to setup and use Eclipse p2 to install new features into an existing application and how to provide auto-update (self-update) functionality for an application.

This article assumes knowledge about Eclipse plugins and Eclipse RCP development.


Table of Contents

1. Eclipse plugin updates and installations
1.1. Overview
1.2. Prerequisites
2. Create feature for p2 installation
2.1. Create plugin and feature project
2.2. Create category
2.3. Export your feature
2.4. Test
3. Create RCP application
4. Add p2 to your RCP application
5. Thank you
6. Questions and Discussion
7. Links and Literature
7.1. Eclipse p2 updater resources
7.2. Other Resources

1. Eclipse plugin updates and installations

1.1. Overview

Eclipse provides an installation and update mechanism called p2. Using this update mechanism allow to install new Eclipse functionality and to update existing. Eclipse p2 can be integrated into Eclipse RCP applications.

1.2. Prerequisites

You should know how to develop Eclipse plugins and Eclipse RCP application. See Eclipse Plugins Tutorial and Developing Eclipse RCP Applications - Tutorial for further information.

2. Create feature for p2 installation

2.1. Create plugin and feature project

Create a Eclipse plugin "de.vogella.p2.add.command" (not RCP) based on the "Hello, World Command" template.

Create a feature project "de.vogella.p2.add.command.feature" which includes the plugin "de.vogella.p2.add.command". See Eclipse Feature Project for details how to create a feature project.

2.2. Create category

In your feature project create file File -> New -> Other -> "Category Definition" a new category for your feature.

Press "New Category" and create a category, e.g. with the name "vogella.de". Add your feature to this category.

2.3. Export your feature

Export your feature via File -> Export -> "Deployable features". Deploy it to a local directory on your machine. Make sure you select on the Option tab your "category.xml". Also make sure to select "Generate metadata repository".

2.4. Test

Try if this feature can be installed into your Eclipse IDE. See Using the Eclipse Update Manager for information on how to use the Eclipse update manager. Use the update manager and point to your local directory. Restart the IDE after installation. You should have a new command after the installation.

After a restart of your Eclipse IDE you should have an additional menu entry.

Using the Eclipse Update Manager revert this installation.

3. Create RCP application

Using the "Hello RCP" template create a Eclipse RCP application in plugin "de.vogella.p2.app". Create a feature "de.vogella.p2.app.feature" which includes plugin "de.vogella.p2.app" and "org.eclipse.rcp".

In the plugin "de.vogella.p2.app" create a new product configuration "app.product". The product should be feature based. Export your product and make sure you can start it. Please see Eclipse RCP for details.

4. Add p2 to your RCP application

Add the feature "org.eclipse.equinox.p2.user.ui" to your product. Adjust your runtime configuration and run your product again. You should see now difference.

The p2 commands attach themself to the menu with the ID "help". Create a menu with the id "help" and re-run your application. See Eclipse Commands Tutorial if you need information on how to define a menu.

If you select the menu you will get an error message.

Export your product then you should be able to open the update manager.

Use the update manager to install your "de.vogella.p2.add.command.feature" feature.

5. Thank you

Thank you for practicing with this tutorial.

Please note that I maintain this website in my private time. If you like the information I'm providing please help me by donating.

6. Questions and Discussion

For questions and discussion around this article please use the www.vogella.de Google Group. Also if you note an error in this article please post the error and if possible the correction to the Group.

I believe the following is a very good guideline for asking questions in general and also for the Google group How To Ask Questions The Smart Way.

7. Links and Literature

7.1. Eclipse p2 updater resources

http://wiki.eclipse.org/Equinox_p2 The Eclipse p2 update wiki

http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application Adding p2 update to an RCP application