Java Reference
In-Depth Information
17.4
SWT AND GCJ
Up to now, we have told you again and again that SWT will work with gcj .
But no Linux distribution with which we are familiar provides SWT with gcj
out of the box. So how do you get SWT to play nice with gcj ? Unfortunately,
you have a bit of work to do. Fortunately, the work is not particularly difficult.
Before we proceed, we must acknowledge those who have been there be-
fore. We, too, had heard about SWT's usability with gcj but we had never
bothered to try it because there was no documentation on how to do it. We
first made the attempt thanks to a great IBM developerWorks article by Kirk
Vogen entitled “Create Native, Cross-Platform GUI Applications.” Follow the
URL 17 to the information that enabled us to write this chapter. 18
SWT source code is included in the Eclipse SDK download. See Sec-
tion 10.4 for details on where and how to download and install Eclipse. Once
you have Eclipse, you need to get your mits on the SWT source code. What
we will do is compile the SWT source into a shared object file that we can link
to any gcj application.
We're assuming that you've got gcj installed. We're assuming that you've
unzipped the Eclipse SDK. We're assuming you're still reading the topic. We
have to make that assumption. The first thing you need to do is to unzip the
SWT source code. It is found in ECLIPSE_INSTALL/plugins/org.eclipse.
platform.linux.gtk.source_2.1.2/src/org.eclipse.swt.gtk_2.1.2/
ws/gtk . If you are using (as we recommend) the GTK version of Eclipse, 19
there are two files in there: swtsrc.zip and swt-pisrc.zip .
Once you have these unzipped, you have to compile the code with gcj .
There are two different patterns these files follow. Files that do not contain
native methods are compiled with a command line that looks like this:
17. http://www-106.ibm.com/developerworks/library/j-nativegui/
18. Please note that Kirk's article provides links to additional documentation and to an ant
buildfile that automates the steps we are going to teach you manually here. We certainly didn't
want to steal anything from Mr. Vogen (or from IBM—scary!), so we will instead direct you
to the (copyrighted) IBM Web resources. The article is worth checking out. It can save you
some time over our version of the process. It is up to you.
19. Be aware: As helpful as Kirk Vogen's article and files are, they are written to an old version
of gcj and they assume you are using the Motif version of Eclipse. His scripts work only with
the Motif version.
Search WWH ::




Custom Search