From Documentation

Jump to: navigation, search


Prepare OSGi running environment

EclipseRT Web Starter Kit

  • Download EclipseRT Web Starter Kits.
  • Click the latest stable version (currently link and download Jetty Server (cross platform) and unzip the file.
  • Rename the unzipped folder name from EclipseRTWebStarterKit-version.timestamp to EclipseRTWebStarterKit.
  • Import this project to Eclipse by Import wizard: General -> Existing Projects into Workspace as illustrated below.
Eclipse osgi01.png

ZK OSGi bundles

since 6.0.2
  • Download ZK OSGi jars.
  • Unzip all zk osgi jars into any folder.
  • Double click file.
Eclipse osgi02.png
  • Click Add button -> choose Directory -> Select the folder that contains zk osgi jars.
Eclipse osgi03.png
  • Click Set as Target Platform link to make it a default target platform to run OSGi Framework.
Eclipse osgi04.png

Run up OSGi environment

  • Right Click EclipseRTWebStarterKit project -> Run As -> Run Configuration -> OSGi Framework -> Start EclipseRT Web Starter Kit
  • Click Add Required Bundles button-> click Run button.
    Eclipse osgi05.png
  • If you see osgi console, then it is correctly installed. You can type help command to check all osgi command usage.
    Eclipse osgi06.png
  • Type close command in the console to shutdown and exit OSGi environment.

Create a Hello World project

  • Follow eclipse wizard to create a new Plug-in project
    1. File -> New -> Other -> Plug-in Project
    2. Type the project name (here I use helloZKOSGi) and in the Target Platform choose an OSGi framework as standard and click Next.
    3. In Properties panel, type ID (helloZKOSGi), Version (1.0.0), Name (Hello ZK OSGi) and Provider (leave blank) information. In Options panel, uncheck Generate an activator since we do not need Activator here. Then, click Next.
    4. Uncheck Create a plug-in using one of the templates since we do not need it here. Click Finish.
  • Create a folder called WEB-INF under the project root.
    • Create web.xml file under WEB-INF folder.
    • Create zk.xml file under WEB-INF folder.
  • Create a hello world zul page under project root.
  • <?page title="Hello ZK OSGi"?>
    <window title="Hello OSGi!!" border="normal" width="200px">
    	<label value="You are using: ${desktop.webApp.version}"/>
  • Open MANIFEST.MF file to edit necessary information.
    1. You will see six tabs: Overview, Dependencies, Runtime, Build, MANIFEST.MF and
    2. In Dependencies tab, add Required Plug-ins for all zk jars
    3. Eclipse osgi07.png
    4. In Build tab, remember to check WEB-INF folder and index.zul file that were created earlier.
    5. Eclipse osgi08.png
    6. In MANIFEST.MF tab, add the following content to the last line that will treat this plug-in project as a web bundle.
    7. Web-ContextPath: /osgi
  • Right click on helloZKOSGi project -> Run AS -> Run Configuration
  • Click Add Required Bundles button and make sure that helloZKOSGi bundle is checked
  • Visit http://localhost:8080/osgi to check the result.

Version History

Last Update : 2012/7/24

Version Date Content

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.