Force Eclipse (Helios) to use a newer version of SWT at application runtime
Asked Answered
L

1

2

I'm developing an RCP project using Eclipse-Helios.

The version of SWT that is installed (in the plugins directory) is [org.eclipse.swt-win32-3.6.2, & org.eclipse.swt.jar]

I require new API functionality that is only available from swt-3.8. (specifically, I wish to set the custom colours, for an SWT color dialog before opening.)

I have downloaded 3.8.1 from the SWT/Eclipse downloads site [ http://download.eclipse.org/eclipse/downloads/drops/R-3.8-201206081200/#SWT ]

  • The SWT download is NOT a plugin (couple of jars, src.zip and some readme files), so I am unable to add it to my "Target Platform" (it doesn't appear as an available jar even after adding the containing directory in "locations")
  • I was unable to find an update site for SWT (or any site where i could get a plugin for the newer version)

If I add the swt.3.8.jar to my classpath (and then increase it's order-priority in the project build-path), I am able to access the newer api functionality from my code (as well as view the source). When I run the application however, it seems as though the runtime is still using the older SWT jar, as i get an unknown method error, when attempting to access the newer functionality.

Questions:

  1. Is there an SWT repository location that I can use to download a newer version of SWT using the eclipse install manager?
  2. If not, is there a way I can force the runtime to ignore the older version (I assume via plugin.xml)?
  3. Is there a better way to achieve what I am trying to do?
  4. What is the difference between the two SWT jars currently in the helios plugins directory (as the 3.8 download only contains the win-32 version)?

Thanks in advance.

Luxuriant answered 7/12, 2012 at 5:59 Comment(0)
U
3

SWT is downloadable as a separate plugin here:
http://download.eclipse.org/eclipse/downloads/drops/R-3.8-201206081200/#SWT

Eclipse 3.8 contains regular plugins including the SWT (the win32 specific as well as the generic "org.eclipse.swt_.jar"). I am currently using the 3.8 version and they appear as plugins.

I also have Eclipse 3.6 (Helios) and I was able to import the swt plugins using the "File->Import->Plug-in Development->Plug-ins and Fragments" wizard. I just specified the eclipse 3.8 directory and could import them in my workspace. Once imported I can of-course use them to be included in the runtime environment. Eclipse should use the latest version automatically.

Uphroe answered 7/12, 2012 at 12:24 Comment(6)
If I download the just win32 SWT package (swt-3.8-win32-win32-x86.zip), then use the method you described, eclipse finds no plugins in the downloaded file/directory. Having to install an entirely new version of eclipse just to use a single library seems like overkill (why not just use the newly downloaded version of eclipse?). There must be a simpler way of achieving this?Luxuriant
Ok if you download the SWT alone from the link above it is already an eclipse project, you can import that using the regular import wizard. I downloaded this link, unzipped in a directory and used File->Import->General->Existing Projects into Workspace wizard to directly import the project. The other solution is for the case if you have a complete Eclipse 3.8 already present.Uphroe
Wait a second... the project is not a plugin. It is a regular Java project. Ok, try this, right click the project after importing and choose Configure->Convert to Plug-in Projects... and this will make it a plug-in. Once you have the plugin you can fix the version (3.8) and might be other things to use it to replace SWT in your target environment. Let me know if this works or we can try something else. Strange that the project is not already a plugin.Uphroe
Thanks for your help Waqas. We're getting there. If I import and convert the project as you describe. I then update the manifest version to 3.8.1. This consequently removes all errors from the script editor (indicating that the newer version is being referenced by the eclipse editor). However, when I run it, I see the same problem as before, NoSuchMethodError. I can't see any way to replace the old SWT in my "target platform" with the new 3.8.1 version. Nor can I add it to my plugin.xml (Not sure if this would even help, as I can't currently see SWT anyway). Any thoughts?Luxuriant
Can you confirm that your new plugin is part of the launch configuration? Maybe it is somehow not included when you launch the application from your Eclipse environment? Although I would also suggest that you download Eclipse 3.8 and also use the 'Plug-ins and Fragments' wizard approach as well. Actually in this latter case you will have a fully functional and configured SWT 3.8 plugin from a running platform, so at least we can factor out settings issues. Once you have imported the plugin you don't need the original Eclipse 3.8 bundle as the plugin is imported as a copy (you may remove it).Uphroe
Ok. So here's what I ended up doing. Downloaded Juno, copied the three swt-plugin jars [swt, source, win32] from juno/pugins to a folder under Helios installation [helios-eclipse/dropins/swt]. opened helios: Window->preferences->plug-in develpoment->Target Platform. On the locations tab, add new plugins from directory. Browse to the new swt folder, and add all three jars. On the content tab, unselect the 'old' swt plugins, and select the 'new' ones. Rebuild. Everything compiles and runs correctly. It's seems a little more complex than necessary, but it worked.Luxuriant

© 2022 - 2024 — McMap. All rights reserved.