Plugable Swing – A Hello World OSGi Example

There are a lot of OSGi applications out, a minority is for the client side. Here I will list some “on swing”:

  1. Apache-Felix-Demo
  2. Swing-Application-on-OSGi from Daniel Rohe
  3. Dynamic Swing OSGi Demo from Kai Tödter
  4. Examples from the OSGi in Action book
  5. Sip-Communicator
  6. Daro

Today I tried the same and had luck. It was very fast (~1h) to get all working what I wanted, because I shamelessly stole the code from the example of Apache Felix. It is even more easier than this example but should have the same effect: it shows how one could use OSGi even for a Swing application.

There is a host application called Swing On OSGi – Host with one JMenu which does not change (static) and one (dynamic) JMenu which could be changed from the available plugins (here only one: Swing On OSGi – PluginTest). The source code (Apache License 2) can be checkout via

svn checkout https://timefinder.svn.sourceforge.net/svnroot/timefinder/branches/swingosgi swingosgi

… you will need maven. After ‘mvn install’ for both projects you will only need to start the host application via your IDE or via

java -jar target/host-1.0.0.jar

Then if you see the “dynamic menu” with one menu entry (which was added from the plugin) all is fine:

helloOSGiWorld

If you have problems while building this send me an email or comment here.

I got the plugins even working in my timetabling application TimeFinder which uses the client-side framework called Spring Rich Client. The first plugin for Spring Rich Client – read more.

About these ads

4 thoughts on “Plugable Swing – A Hello World OSGi Example

  1. Pingback: Plugable Spring RC? (OSGi with Spring Rich Client) « Find Time for Java and more!

  2. This is an incredibly useful example and very easy to install and run! The use of Swing in OSGi is almost completely overlooked by the most popular books and online tutorials.

Comments are closed.