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

NewProject

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

FragmentProject1

Fill in the Project Name and hit ‘Next’

FragmentProject2Blank

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

PluginSelectionBlank

We are actually interested in the code in the package

       org.eclipse.jdt.ui.wizards

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

       org.eclipse.jdt.ui

bundle.

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

PluginSelection

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

FragmentProject2

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
!STACK 1
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

       -d32

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

RunConfigurations

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

Advertisements

1 Comment »

  1. NICE! Took me a couple of hours of hunting to find this post, but it fixed the exact problem I was having.
    Hooray for -d32!

    Stupid eclipse black magic. Documentation = NONE.

    Comment by luke — March 31, 2010 @ 12:37 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: