Using OSGi in a desktop standalone application
Your code is basically okay, but it sounds like you want more control over the OSGi framework itself. In other words, you want to know how to launch an OSGi framework and start your bundle. The problem you have currently is that you're using somebody else's launcher (the Knopflerfish one) which includes the KF GUI Console, and you are using that to install and start your bundle. However none of that is necessary.
In AValchev's answer he talks about starting Equinox with java -jar org.eclipse.osgi.jar -console
. The trouble with that approach is that it gives you an empty OSGi framework, so you will have to type commands into the OSGi shell in order to install and start your bundle... also not ideal!
I think you should write your own launcher. This is actually very simple and can be done in a way that is completely independent of any particular OSGi framework implements. I wrote about this in a blog post a little while ago.
In pseudo-code, your launcher application should look something like this:
public static void main() {
1. get a FrameworkFactory using java.util.ServiceLoader.
2. create an OSGi framework using the FrameworkFactory
3. start the OSGi framework
4. Install your bundle(s).
5. Start all the bundles you installed.
6. Wait for the OSGi framework to shutdown.
}
In your question you specifically ask about setting the bundle storage location. This can be done by setting the Constants.FRAMEWORK_STORAGE
property in the Map that you pass into FrameworkFactory.newFramework
method.