views:

179

answers:

3

I need to add Plugin support to a Java Swing App (like in Eclipse).

The Plugin should have the ability to add new Menu items and tab components to the swing app.

I am looking for frameworks or libraries which support it. So far I have found Java Plugin Framework http://jpf.sourceforge.net/ and planning to use it.

Are there any other better alternatives to it?

A: 

There is Netbeans RCP. In addition to plugin framework it provides window docking system which may be very useful in your app (you can easily add and remove menu items and tab components in plugins using xml-files for example). But framework is big and you have to do some things netbeans-way.

Ha
I checked Netbeans RCP, but it seems to be too big for my requirement. Also I don't need docking support. Anyways thanks for the suggestion.
Sudar
+1  A: 

You can use the plugin system from eclipse/osgi without using SWT. This is a minimal standalone "Hello world" application. You extending the extension point "org.eclipse.core.runtime.applications" and can put whatever you like in the Application class. You can generate an exe as launcher using eclipse and using the RCP framework from it.

package test;

import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext;

Application.java

public class Application implements IApplication {

    public Object start(IApplicationContext context) throws Exception {
        System.out.println("Hello world!");
        return IApplication.EXIT_OK;
    }

    public void stop() {
        System.out.println("By by!");
    }
}

plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         id="application"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run
               class="test.Application">
         </run>
      </application>
   </extension>

</plugin>

MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: Test; singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Arne
Does it support adding menu items and tabs to my swing app? Also can you send me a link from where I can read more about it. Thanks!
Sudar
You would get plugin support, nothing more. To adding swing (!) menu items tabs etc. you would have to define your own extension points. A good starting point for articles is here: http://www.eclipse.org/resources/. To learn about the plugin system maybe you want to read http://www.eclipse.org/articles/Article-Plug-in-architecture/plugin_architecture.html.
Arne
I think you misunderstood the question. I wanted to add Plugin support to my Java Swing app, not create a Eclipse Plugin.
Sudar
I have understand what you said. You can use eclipse/osgi to add plugin support to your swing app. But maybe it's to big and to invasive for your requirements.
Arne
A: 

Even though using OSGi/Equinox would be the best option - there is an alternative solution. It is called Java Plugin Framework. Take a look at it here

http://jpf.sourceforge.net/

eugener
Yeah jpf is the one which I initially looked. I just wanted to see if there are any other good alternatives to it.
Sudar