Creating an OSGI bundle from jar

Step 1: Start by creating jar’s manifest file: “manifest.txt”

Manifest-Version: 1.0

Created-By: yourname

Bundle-ManifestVersion: 2

Bundle-Name:  Junit 4.4 bundle

Bundle-Description: Package junit 4.4 is an OSGI bundle

Bundle-Version: 4.4.0

Bundle-ClassPath: .,junit-4.4.jar

Bundle-SymbolicName: org.junit.framework

Export-Package: *

  • Bundle-ClassPath header is set to allow embedding the original jar as is. Make sure its value matches the filename of the jar that you are going to embed in the bundle.
  • Export-Package is a list of packages contained in the jar that you would like to make available to other bundles running the OSGI Container. 

Step 2: Create the bundle jar file by running the following command:

jar cvfm junit-4.4-bundle.jar manifest.txt junit-4.4.jar

where manifest.txt is the name of the manifest file created above. junit-4.4-bundle.jar is the name of the bundle.

That’s it. Your bundle is ready to be installed.

Leave a comment