Run an Eclipse 32-bit application from a 64-bit Eclipse IDE
Typically the development environment should not be dependent on the target environment the application should run on. For creating an Eclipse RCP application using SWT, this is not as trivial as it looks like. The reason for this is the fact that the SWT implementation is packaged in platform dependent bundle fragments. But it is possible to setup the workspace to make that work, which I will show in the following blog post.
You need to maintain an Eclipse RCP application that makes use of 32-bit Windows native libraries. Since you got a brand new laptop or PC that runs a 64-bit Windows, you install the 64-bit version of Eclipse. As you are aware that you need to execute the application in a 32-bit JVM, you add a 32-bit JDK via Window -> Preferences -> Java -> Installed JREs and configure that JDK as the default for the JavaSE-1.8 Execution Environment.
At development time you want to start your application from the IDE, e.g. via .product file -> Launch an Eclipse application. But you get the following error:
java.lang.UnsatisfiedLinkError: Cannot load 64-bit SWT libraries on 32-bit JVM
The reason for this is clear, you installed a 64-bit Eclipse, therefore you only have the 64-bit bundle fragment of SWT in your installation. But you need the 32-bit SWT fragment. This can be solved easily by configuring the target platform appropriately.
- Create a new Target Platform
- Switch to the Environment tab in the PDE Target Editor
- Change the Architecture to x86
- Switch to the Definition tab
- Click Reload (this is important to retrieve the x86 fragments!)
- Switch to the Content tab and check if the correct fragment is now part of the target platform (check for the
- Activate the target platform via Set as Target Platform
Now it is possible to execute a 32-bit application from a 64-bit Eclipse IDE via .product file -> Launch an Eclipse application.
Note: Remember to start via the .product file and not via an existing run configuration, because the run configuration needs to be updated for the environment settings.