A look at FWT, SWT and how to install it on 64-bit platforms.
The Fantom Widgit Toolkit (FWT) is a toolkit for building both desktop and HTML5 browser applications. FWT is a wrapper around the Standard Widget Toolkit (SWT) from Eclipse.
Part of the reason why SWT is so awesome and integrates so well into your native windows environment is because it relies on platform specific native code. This means to run FWT applications on your desktop, SWT has to be installed on your system. This also means there are a number of different SWT downloads, one for each platform. A platform being Win, Win 64-bit, Linux, Linux 64-bit, Solaris, etc... you get the picture!
Fantom comes pre-bundled with a couple of common SWT platforms, but not all of them. A couple of notable omissions are Windows 64-bit and Linux 64-bit.
Does Fantom support my platform?
An easy way to determine if the standard Fantom install supports your platform is to run a desktop application and see if it works. flux is a desktop app that comes with Fantom, so run it and see what happens:
C:\> flux sys::Err: java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Widget fwt::Desktop.appName (Desktop.fan) flux::Main.main (Main.fan:18) java.lang.reflect.Method.invoke (Method.java:597) fan.sys.Method.invoke (Method.java:559) fan.sys.Method$MethodFunc.callList (Method.java:198) fan.sys.Method.callList (Method.java:138) fanx.tools.Fan.callMain (Fan.java:173) fanx.tools.Fan.executeType (Fan.java:140) fanx.tools.Fan.execute (Fan.java:41) fanx.tools.Fan.run (Fan.java:298) fanx.tools.Fan.main (Fan.java:336)
If you see the stack trace above then you need to install SWT for your platform.
Installing SWT
Installing SWT is as simple as copying a .jar
file into your Fantom home directory.
But to download the correct version of SWT you need to know which platform you have. Run the following command:
C:\> fan -version Fantom Launcher Copyright (c) 2006-2013, Brian Frank and Andy Frank Licensed under the Academic Free License version 3.0 Java Runtime: java.version: 1.6.0_45 java.vm.name: Java HotSpot(TM) 64-Bit Server VM java.vm.vendor: Sun Microsystems Inc. java.vm.version: 20.45-b01 java.home: C:\Apps\Java\jdk1.6.0_45\jre fan.platform: win32-x86_64 fan.version: 1.0.67 fan.env: sys::BootEnv fan.home: C:\Apps\fantom-1.0.67
And make a note of the fan.platform
value. As you can see, mine is win32-x86_64
(Windows 64 bit), yours may be different.
Next, download SWT for your platform. Fantom (as of v1.0.67) uses SWT v4.2.2. You can download it from the eclipse website below.
Note that at time of writing, the download page linked from the SWT home page doesn't exist! So use the direct link above.
File links for some popular platforms are given below. They're also hosted on Alien-Factory should the eclipse links go dead.
- Windows 64-bit: swt-4.2.2-win32-win32-x86_64.zip (6.3 MB) or download from Alien-Factory
- Linux 64-bit: swt-4.2.2-gtk-linux-x86_64.zip (5 .6 MB) or download from Alien-Factory
From the .zip
file, extract swt.jar
.
This swt.jar
needs to be copied into your Fantom home directory. Specifically it needs to be copied to:
<fan-home>/lib/java/ext/<platform>/swt.jar
where platform
is the value you noted earlier. Create the directory if it does not exist.
So on my machine I would copy it to:
C:\Apps\fantom-1.0.67\lib\java\ext\win32-x86_64\swt.jar
And now when you run flux you should see:
Happy FWT developing!
Also see SWT Support on fantom.org.