SWT and JME in an Eclipse View

Hi all,

I have been trying in vain for several hours to get JME to run successfully within an Eclipse view. I have tried various solutions such as using the swt-jme code posted by The Librarian and source from the MW3D code base.  I did eventually get something into a view but several problems then occurred, either with the Input System or trying to run my plugin integrated into a standalone RCP application. Ideally I would like to use the JMEView class from MW3D. As mentioned, I did get this working but then could not get the input to work properly (FirstPersonHandler through an exception stating that the Display had not been created although I was staring right at it…). Using the code from The Librarian also worked up until I tried to deploy the application, at which point I got classpath issues with the META-INF/services directory. I feel I have now exhausted my options and am seeking some sage advice.

I would consider myself a proficient RCP developer and know my way around plug-in deployment, the usual classpath gotchas etc. but this really has me stumped.  I would be extremely grateful if anyone could help me to get through the following scenario with the least amount of fuss, the second point outlining the area I require assistance with:

  • Create an Eclipse RCP application with a view (taken care of)

  • Integrate code to allow me to use JME within the view (help please)

  • Package the app up and deploy as an RCP application (I can do this but have been hitting some classpath issues)

Many thanks in advance,

Hi TigerScot,

I can help a little bit with the Input stuff here:

Currently we didn't utilize the jme input handlers for the our views, but here what you can do:


                input = new FirstPersonHandler( component.getCamera(), 1,
                1 );

This can be called after the construction of the SWTCompositeGame, this is the first peice that you have to make in order to get the input system created. Of course now that you have a reference to that input handler created, then you have to update it.
In the update method put ( input.update( tpf ) ), and this will update the input. The mouse didn't work unless I call MouseInput.update() in the update method as well.

I believe that you have used the jme-mw3d plug-in to start, which is the what you need to get your application up and running with out the depencies on the MonkeyWorld3D plug-in, which means only include jme-mw3d to build you application. Just check it out, create a new RCP application, create a view which extend the JMEView, and you are done.

Hopefully that was helpful.

Hi Outrunner,

Thanks very much for the speedy reply. I knew that there was something I'd have to do to get the input working for me as it wasn't created by default - just didn't know what :wink: I'll give that a go forthwith along with your other suggestion about the jme-mw3d plugin which was kind of what I was trying to do originally. Thanks again for the advice.



Hi again Outrunner,

I am happy to report success after following your advice  :smiley: The following is what I came up with in a JMEView subclass, adding a single Box node for testing:

public class View extends JMEView {

   private FirstPersonHandler input;

   protected void initGame() {
                input = new FirstPersonHandler( display.getCamera(), 1, 1 );

               Box b = new Box("Mybox", new Vector3f(0,0,0), new Vector3f(1,1,1));
               rootNode.attachChild(b); // Put it in the scene graph                

   protected void update(float interpolation) {
      input.update( interpolation );

I take it this is what you had in mind? I notice that the SWTCompsiteGame class already has an 'input' instance variable so wasn't completely sure about creating my own in the View.
The only thing is that the 'W' and 'S' keys appear to perform the reverse function from normal (i.e. 'W' moves out and 'S' moves in). Can't have everything I suppose....


Hi TigerScot,

Glad that I have helped with it, yes you can use the input supplied from the base class, but you have to intialize it as you have done, I just seen it :D.

I take it this is what you had in mind?


The only thing is that the 'W' and 'S' keys appear to perform the reverse function from normal (i.e. 'W' moves out and 'S' moves in). Can't have everything I suppose....

May be its a camera issue, I will have to check for that.


Hi Outrunner,

Thanks for that. The 'A' and 'D' keys also appear to be reversed, so it may well be a Camera issue.



Hi Outrunner,

I tried to use the mw3d library in an Eclipse plugin and use the code snippet you provided above. Unfortunately, using jME 1.0 and Eclipse 3.4, I get the following stack trace when trying to open the view:

[pre]java.lang.NoSuchMethodError: com.jme.system.DisplaySystem.createCanvas(IILorg/eclipse/swt/widgets/Composite;)Lorg/eclipse/swt/opengl/GLCanvas;

at com.jme.renderer.SWTCompositeGame.initControls(SWTCompositeGame.java:157)

at com.jme.renderer.SWTCompositeGame.<init>(SWTCompositeGame.java:125)

at org.mw3d.jme.JMEView$1.<init>(JMEView.java:20)

at org.mw3d.jme.JMEView.createPartControl(JMEView.java:20)

at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:371)

at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230)

at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)

at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2091)

at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1019)

at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3669)

at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)

at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3666)

at org.geocraft.ui.internal.volume2.VolumePlot2.run(VolumePlot2.java:37)

at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)

at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)

at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:582)

at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:499)

at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:410)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:83)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3773)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3372)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2375)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2339)

at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2205)

at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:478)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:473)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

at org.geocraft.Application.start(Application.java:34)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)

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:362)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)

at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(Main.java:1212)


Is there something I am missing? What version of jME does MW3D support?