How to Write, Compile and Execute a SWT Application =================================================== =================================================== Introduction ============ I have spent today looking at SWT and Eclipse as potential technologies for WCKER's implementation. SWT is a replacement GUI API for Java (instead of the usual AWT/Swing) and Eclipse is an integrated IDE for Java development which can also do CVS stuff. For "looking at", read "trying to get to work" ! :-) I didn't help that the instructions in the online tutorials are wrong, and the standard tutorial example does not itself work. Finally, I managed to find an online forum where some of these issues were discussed ..... phew!!!!!! The next section documents my hard-won findings of how to produce a working SWT application. Developing a SWT application ============================ Source Code ----------- import org.eclipse.swt.widgets.*; import org.eclipse.swt.*; /**/ public class SWTHello { public static void main(String[] args) { MessageBox m = new MessageBox(new Shell()); m.setMessage("Hello, World"); m.open(); } } Compilation ----------- javac -classpath /usr/eclipse/eclipse/plugins/org.eclipse.swt.gtk_3.0.1/ws/gtk/swt.jar:/usr/eclipse/eclipse/plugins/org.eclipse.swt.gtk_3.0.1/ws/gtk/swt-pi.jar SWTHello.java Notes: (1) Only one of the two necessary JAR files was mentioned in the tutorials. (2) /usr/eclipse is the local installation root of Eclipse (3) It is also possible to supply these command line arguments through the CLASSPATH environment variable. Execution --------- java -classpath /usr/eclipse/eclipse/plugins/org.eclipse.swt.gtk_3.0.1/ws/gtk/swt.jar:/usr/eclipse/eclipse/plugins/org.eclipse.swt.gtk_3.0.1/ws/gtk/swt-pi.jar:. -Djava.library.path=/usr/eclipse/eclipse/plugins/org.eclipse.swt.gtk_3.0.1/os/linux/x86/ SWTHello Note: (1) As SWT also uses a native (i.e. 'C') library, then one has to not only specify where Java objects can be found but also 'C' objects i.e. more variables to get wrong. (2) It is also possible to supply these command line arguments through the CLASSPATH and LD_LIBRARY_PATH environment variables. Conclusion ========== I am able now to build and run small SWT applications, both inside and outside the Eclipse IDE. Only the command-line solutions are provided for succinctness. The next stage is to assess the ease of implementing some initial WCKER pages in SWT. Eclipse also contains an interactive graphical Java debugger (to be checked out): this is particularly good news (fingers crossed) as the stand-alone Java debuggers I tried out earlier in the project were universally poor! David