0xbadf00d
0xbadf00d

Reputation: 18178

Exporting an GEF-Editor as a runnable JAR

As stated in the title: I want to run an Eclipse-Plugin, more specifically a GEF-Editor, without starting an Eclipse instance before.

I've tried to use the export functionality provided in the MANIFEST.MF file: enter image description here

However, running the generated JAR (call it editor.jar) by executing java -jar editor.jar on the command line fails with the message no main manifest attribute, in plugins editor.jar.

I'm aware of the fact, that this is because my MANIFEST.MF file is missing the following line

Main-Class: <packagename>.<classname>

which defines an entry point for my application. However, I've no idea what exactly I need to do here (in the case of an Eclipse-Plugin), cause I don't have something like a main method. I assume Eclipse is running some magic code it doesn't show to me, when I start my project as an Eclipse Application.

So, what do I need to do?

Upvotes: 0

Views: 118

Answers (2)

s.d
s.d

Reputation: 4185

Wrap your GEF editor in a simple RCP. You can create one via the Plug-in wizard, setting "Would you create a rich client application?" to "Yes" in the process. This gives you the option to create a minimal application via the Hello World template in the next step. Once you have this, you can either embed your GEF editor in this plugin, or declare a dependency from the new RCP application to your GEF editor plugin, and start the editor from the Application class' start method.

For an overview of resources about RCP development, cf. Getting started with the Eclipse RCP.

It really doesn't add that much overhead to your editor but gives you the opportunity to work with the platform's workbench and workspace metaphors and create easy-to-deploy-and-use application bundles.

Once you have that in place, you can test your RCP from plugin.xml > Overview > Testing > Launch an Eclipse application. This will not run a whole new instance of the IDE, but just the RCP application itself.

Rather than exporting from the MANIFEST.MF, look into creating a product (you can do it via the wizard: New > Product Configuration), and building it via the Maven Tycho plugin(s) (have a look at the respective - really worthwhile - tutorial from EclipseCon Europe 2012: http://eclipsecon.org/europe2012/sessions/building-eclipse-plugins-and-rcp-applications-tycho.html, this includes a section on creating a product as well). Tycho gives true cross-platform builds, as long as you're not on Windows.

No magic code there :).

Upvotes: 0

aboyko
aboyko

Reputation: 1557

You could try running a GEF editor as a Java application. See Draw2D examples to understand how it can be done. You could probably re-use your GraphicalViewer and PaletteViewer, which means that mouse based interactions with the diagram and palette will be preserved. However, your editor class would probably have to be incorporated into an SWT shell. Also, all actions contributed to by your editor into Eclipse toolbars, popup menus etc. would be gone. Outline and Tree view would have to be incorporated into your java app somehow if needed. Think you'd be better off with an RCP application.

Upvotes: 1

Related Questions