Third Party Jar Integration

You can use following document to convert jar in to OSGI bundle

In our case Third party jar are under /apps/dvdrental/dvdrental/libs

To convert them in to bundles 

Option 1:

jar cvfm jtmdb-1.9.12 manifest.txt jtmdb-bundle.jar

Manifest file will look like this

Manifest-Version: 1.0
Created-By: yogesh
Bundle-ManifestVersion: 2
Bundle-Name: JTMB bundle
Bundle-Description: JTMB bundle for dvdRental
Bundle-Version: 4.4.0
Bundle-ClassPath: .,jtmdb-1.9.12.jar,json-20080701.jar
Bundle-SymbolicName: net.sf.jtmdb
Export-Package: net.sf.jtmdb
Import-Package: org.json.JSONException,org.json

After bundle is created you can put them in /apps/dvdrental/install folder, So that they can be picked by Felix. Once in Install Folder you will see them in felix console

Option 2:

Other option is use sling boot delegation to add third party jar. I would recommend felix console though as using boot delegation required restart.

Option 3:

Using BND tool

1) Install attached bnd.jar
2) Use command java -jar bnd.jar wrap {YourJarfile}.jar
3) Rename .bar file to {file-name}-bundle.jar
4) Put it in install folder or install using felix console

Create OSGI bundle using BND with additional property

java -jar bnd.jar wrap -properties bundle.bnd {YourJarfile}.jar
Export-Package: *
Private-Package: *
Bundle-Version: 1
Bundle-Classpath: .,{yourjarfile}

Some more useful doc

yogesh upadhyay,
Mar 16, 2012, 5:18 PM