The relevant bits are in bold. It tells the plug-in to add to our MANIFEST certain properties: an
Export-Package directive and a Bundle-Activator header. The Export-Package directive tells the OSGi
environment that this jar, a “bundle,” vends the classes in that package, and that those classes should be
made visible to the client. The Bundle-Activator directive describes to the OSGi environment which
class implements BundleActivator , and should be consulted when life-cycle events occur.
The preceding plug-in takes care of specifying upon which other bundles our bundle depends, using
the Import-Package directive. The final, resulting MANIFEST.MF is telling.
Created-By: Apache Maven Bundle Plugin
This describes the dependencies, exports, and layout of the bundle fully to the OSGi runtime, and
makes it easy for clients to know what they're getting when they use this bundle. Take your compiled
classes, the finalized META-INF/MANIFEST.MF, and jar them up.
This rounds out the code for the service. Let's install it into the OSGi environment and then start in
using it as a client. The installation procedure is very specific to each tool.
against 3.4.2) and unzipped it, change to the installation directory and, on the command line, type:
java -jar eclipse/plugins/org.eclipse.osgi_YOUR_VERSION.jar -console
Naturally, substitute YOUR_VERSION for the one that applies to the version of the distribution that
you downloaded. We're using 3.4, which is the latest stable release. This will start an interactive session.
You can type help to see the list of available commands. You can issue the services command to list the
bundles already installed. To install the bundle, assuming you've put the jar produced from previous
steps for the service at the root of your file system ( C:/ , or / , perhaps?) issue:
install file://helloworld-service-1.0-SNAPSHOT.jar o r install file:/C:/helloworld-service-
This installs the jar in the OSGi registry and produces an ID that can be used to refer to the bundle.
Use it as the operand to the start command.