Just An Application

October 29, 2009

An Extended NewAnnotation Wizard For Eclipse: Getting Started

Because I wanted to re-use the existing Eclipse NewAnnotation wizard code, if at all possible, I decided to create a fragment hosted by the bundle containing the code for the Eclipse Java type creation wizards, rather than a stand-alone bundle. Note that Eclipse uses the term ‘plug-in’, but an Eclipse ‘plug-in’ is an OSGi bundle with some added stuff, and I’m going to stick to the term bundle.

To do this select ‘New’ from the ‘File’ menu on the toolbar, ‘Project’ from the resulting sub-menu and ‘Fragment Project’ from the ‘Plug-in Development’ section of the resulting dialog


Hit ‘Next’ and you will get the first page of the ‘New Fragment Project’ wizard


Fill in the Project Name and hit ‘Next’


The Host Plug-in (bundle) section needs to be filled-in, so hit ‘Browse’ and you will get the ‘Plug-in Selection’ dialog show below


We are actually interested in the code in the package


but which bundle is it in ?

The mapping of packages to JDT bundles can be found in the JDT Plug-ins Map which shows that we are after the



Entering this is in the text field at the top gets us two matches


Picking the top-most one and hitting ‘OK’ gets us back to the second page


That’s it. Hit ‘Finish’, respond to the resulting dialog about opening the associated perspective and its done.

Not that it does currently does anything but the resulting fragment can be ‘run’ by selecting the ‘run’ button from the toolbar and then selecting ‘Eclipse Application’ from the ‘Run As’ sub-menu, unless you are running Eclipse on Snow Leopard, that is, in which case you may get an error dialog instead, and a log containing the following

!ENTRY org.eclipse.osgi 4 0 2009-10-29 21:13:30.206
!MESSAGE Application error
java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
	at org.eclipse.swt.internal.Library.loadLibrary(Library.java:182)
	at org.eclipse.swt.internal.Library.loadLibrary(Library.java:159)
	at org.eclipse.swt.internal.C.(C.java:21)
	at org.eclipse.swt.internal.cocoa.NSThread.isMainThread(NSThread.java:33)
	at org.eclipse.swt.graphics.Device.(Device.java:116)
	at org.eclipse.swt.widgets.Display.(Display.java:628)
	at org.eclipse.swt.widgets.Display.(Display.java:619)
	at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:532)
	at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)
	at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:143)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:88)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

which is a bit of a pain

Fortunately it is easily fixed.

Bring up the ‘Run Configurations’ dialog, using ‘Run Configurations …’ from the menu on the ‘run’ button for example, select ‘Eclipse Application’ then select the ‘Arguments’ tab.

In the ‘Program arguments’ text box at the top prepend the argument


as shown below. This tells the VM not to mess about with all that 64-bit stuff, or something like that.


Try ‘running’ the fragment again and you should now get a second copy of Eclipse uncannily similar to the one you are already running.

Copyright (c) 2009 By Simon Lewis. All Rights Reserved


Create a free website or blog at WordPress.com.

%d bloggers like this: