13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

396Chapter 17Other Ways: Alternatives to Swing17.4SWT AND GCJUp to now, we have told you again and again that SWT will work with gcj.But no <strong>Linux</strong> distributi<strong>on</strong> with which we are familiar provides SWT with gcjout 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 before.We, too, had heard about SWT’s usability with gcj but we had neverbothered to try it because there was no documentati<strong>on</strong> <strong>on</strong> how to do it. Wefirst made the attempt thanks to a great IBM developerWorks article by KirkVogen entitled “Create Native, Cross-Platform GUI <str<strong>on</strong>g>Applicati<strong>on</strong></str<strong>on</strong>g>s.” Follow theURL 17 to the informati<strong>on</strong> that enabled us to write this chapter. 18SWT source code is included in the Eclipse SDK download. See Secti<strong>on</strong>10.4 for details <strong>on</strong> where and how to download and install Eclipse. Onceyou have Eclipse, you need to get your mits <strong>on</strong> the SWT source code. Whatwe will do is compile the SWT source into a shared object file that we can linkto any gcj applicati<strong>on</strong>.We’re assuming that you’ve got gcj installed. We’re assuming that you’veunzipped the Eclipse SDK. We’re assuming you’re still reading the book. Wehave to make that assumpti<strong>on</strong>. The first thing you need to do is to unzip theSWT 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 versi<strong>on</strong> of Eclipse, 19there 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 c<strong>on</strong>tainnative 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 additi<strong>on</strong>al documentati<strong>on</strong> and to an antbuildfile that automates the steps we are going to teach you manually here. We certainly didn’twant to steal anything from Mr. Vogen (or from IBM—scary!), so we will instead direct youto the (copyrighted) IBM Web resources. The article is worth checking out. It can save yousome time over our versi<strong>on</strong> 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 versi<strong>on</strong>of gcj and they assume you are using the Motif versi<strong>on</strong> of Eclipse. His scripts work <strong>on</strong>ly withthe Motif versi<strong>on</strong>.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!