Tuesday, February 06, 2007

Knopflerfish OSGi tutorial

Thanks to some Australian OSGi users for providing a nice link to a Knopflerfish OSGi tutorial.

My example of how to create an OSGi bundle in under 10 minutes still takes some beating for simplicity (or triviality, if you prefer), but I do believe in giving beginners a really easy way in. If they're smart, they'll soon catch on.


AlBlue said...

Easy? You want easy?

In Knopflerfish, go to 'File->Open URL'. Then paste in http://www.bandlem.com/HelloWorld.jar.

Lo, it says Hello world. Stop it, it says Goodbye World. Start it again, and it says Hello world.

Now that's easy.

PS You really shouldn't install remote code; you never know what it's doing ;-) But it comes with full source (ahem, one class) in case you want to build it yourself.

Glyn said...

Not that easy! ;-)

Coding it yourself (albeit using cut and paste), removes any sense of 'smoke and mirrors'.

AlBlue said...


--- >8 --- HelloWorld.java
import org.osgi.framework.*;
public class HelloWorld implements BundleActivator {
public void start(BundleContext context) {
System.out.println("Hello World");
public void stop(BundleContext context) {
System.out.println("Goodbye World");
--- >8 --- Manifest.MF
Manifest-Version: 1.0
Bundle-Name: HelloWorld
Created-By: Alblue
Bundle-Activator: HelloWorld
Bundle-SymbolicName: HelloWorld
Bundle-Version: 1.0.0
--- >8 ---
javac -cp framework.jar HelloWorld.java

jar cfm Manifest.MF HelloWorld.class


Glyn said...


AlBlue said...

NB the manifest should have:

Import-Package: org.osgi.framework;version=1.3.0

since Equinox 3.3 has more strict checking than Equinox 3.2 did.

Kit Plummer said...

Just a "nit"...

The jar command should be:

jar cfm HelloWorld.jar Manifest.MF HelloWorld.class

Glyn said...

Thanks Kit.


OSGi (130) Virgo (59) Eclipse (10) Equinox (9) dm Server (8) Felix (4) WebSphere (3) Aries (2) GlassFish (2) JBoss (1) Newton (1) WebLogic (1)

Blog Archive