Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:21:41+00:00 2026-05-27T12:21:41+00:00

I am trying to write an OSGi based desktop application. I have a Swing

  • 0

I am trying to write an OSGi based desktop application. I have a Swing JFrame and I want to add possibilities to add modules (other bundles). I walked through EclipseZone OSGi at JSig tutorial, but every application is started from OSGi Framework (in this case, Knopflerfish OSGi Desktop).

So my question is, whether there is an option to start the application without visible OSGi frame? I knwo, that from code, it is possible to change properties of a bundle, but how to change properties of a framework that way? (e.g. default bundle storage location, default action when bundle is in location etc.?)

public class MainFrame extends ServiceTracker implements BundleActivator {

    public MainFrame(BundleContext context, JToolBar toolBar) {
        // select, which services is the bundle tracking
        super(context, JMenu.class.getName(), null);
    }

    @Override
    public void start(BundleContext context) throws Exception {
        //display a JFrame
    }

    @Override
    public void stop(BundleContext context) throws Exception {
        //hide a JFrame
    }

    @Override
    public Object addingService(ServiceReference reference) {
        // Process a Service and return a JMenu
        return new JMenu();
    }

    @Override
    public void removedService(ServiceReference reference, Object service) {
        // remove a JMenu from a JFrame
    }

    public static void main(String[] args) {
        // ????????????????????????????????????????????
        // ????????????????????????????????????????????
    }
}

I’ve written a class above (I’ve posted just a sketch), but I have no idea, what to write in a main() function. This bundle works fine in Knopflerfish OSGi Desktop, but I want it to run without it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:21:41+00:00Added an answer on May 27, 2026 at 12:21 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying write a query to find records which don't have a matching record
Im trying to write something to get my images to show correctly. I have
I have a legacy application that I'm trying to port to Java EE. Presently
Trying to write a python application that downloads images from an RSS feed, and
I've been trying write an application which will be able to connect to a
In trying to write more testable Java code, I have been using the Model-View-Presenter
Im trying to write a single activity app, extending ListActivity. I have a class
Trying to write a PowerShell cmdlet that will mute the sound at start, unless
Trying to write a couple of functions that will encrypt or decrypt a file
Im trying to write a single byte at a certain location in a file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.