Java™ApplicationDevelopmentonLinux®
ByCarlAlbing,MichaelSchwarz
Publisher :PrenticeHallPTR
PubDate :November22,2004
ISBN :0-13-143697-X
Pages :600
Readerslearnhowto:
Tableof
•
Contents
• Index
UsedevelopmenttoolsavailableonLinux,suchastheGNU
CompilerforJava(gcj),Ant,theNetBeansIDE,IBM's
EclipseJavaIDE,JUnit,andSunONEStudio
DevelopbusinesslogiclayersusingJavaDataBase
Connectivity(JDBC)
AddaWebinterfaceusingservletsandJSPs
AddaGUIusingSun'sAbstractWindowToolkit(AWT)and
IBM'sSWT
DeployEJBsinLinux
Theauthorsconcludebydemonstratinghowahierarchyof
budgetscanbecreated,tracked,andsharedwithConcurrent
VersionsSystem(CVS).AcompanionWebsiteincludesallsource
codeandalinktoeachtooldescribed.
Java(TM)ApplicationDevelopmentonLinux(R)canpropel
youfromastandingstarttothefull-speeddevelopmentand
deploymentofJavaapplicationsonLinux.
Java™ApplicationDevelopmentonLinux®
ByCarlAlbing,MichaelSchwarz
Publisher :PrenticeHallPTR
PubDate :November22,2004
Tableof
ISBN :0-13-143697-X
•
Contents
Pages :600
• Index
Copyright
BrucePeren'sOpenSourceSeries
Preface
JavaandLinux
FreeSoftwareandJava
YouCanHelp!
Acknowledgments
Introduction
WhoShouldBuyThisBook
WhoShouldNotBuyThisBook
HowtoUseThisBook
PartI:GettingStarted
Chapter1.AnEmbarrassmentofRiches:TheLinuxEnvironment
Section1.1.WhatYouWillLearn
Section1.2.TheCommandLine:What'stheBigDeal?
Section1.3.BasicLinuxConceptsandCommands
Section1.4.Review
Section1.5.WhatYouStillDon'tKnow
Section1.6.Resources
Chapter2.AnEmbarrassmentofRiches:Editors
Section2.1.WhatYouWillLearn
Section2.2.EyetoEyewithvi
Section2.3.EditorsGalore
Section2.4.Review
Section2.5.WhatYouStillDon'tKnow
Section2.6.Resources
Chapter3.AnExperiencedProgrammer'sIntroductiontoJava
Section3.1.WhatYouWillLearn
Section3.2.FundamentalLanguageElements
Section3.3.Using(andMaking)JavaAPIs
Section3.4.Encapsulation,Inheritance,andPolymorphism
Section3.5.O,Templates!WhereArtThou?
Section3.6.VirtuallyFinal
Section3.7.AUsefulSimpleApplication
Section3.8.Review
Section3.9.WhatYouStillDon'tKnow
Section3.10.Resources
Section3.11.Exercises
Chapter4.WhereAmI?ExecutionContext
Section4.1.WhatYouWillLearn
Section4.2.ASimpleStart
Section4.3.TheSystemClass
Section4.4.ThePropertiesClass
Section4.5.TheRuntimeClass
Section4.6.Review
Section4.7.WhatYouStillDon'tKnow
Section4.8.Resources
Chapter5.TheSunMicrosystemsJavaSoftwareDevelopmentKit
Section5.1.WhatYouWillLearn
Section5.2.AllYouNeed,andNotOneThingMore
Section5.3.TheJavaCompiler
Section5.4.TheJavaRuntimeEngine
Section5.5.Complete,Up-to-DateProgramDocumentationMadeEasy
Section5.6.DispensingwithApplets
Section5.7.GoingNative
Section5.8.IntroducingRMI
Section5.9.TheJavaDebugger
Section5.10.ReturntotheSource:TheJavaDecompiler
Section5.11.BundlingaJavaProgram:PutitinaJAR
Section5.12.TheRestoftheToolkit
Section5.13.Review
Section5.14.WhatYouStillDon'tKnow
Section5.15.Resources
Chapter6.TheIBMDeveloperKitforLinux,Java2TechnologyEdition
Section6.1.WhatYouWillLearn
Section6.2.UseLinuxFeaturestoMakeMultipleJavaSDKsPlayNicely
Together
Section6.3.HowtheIBMJDKDiffersfromtheSunJDK
Section6.4.WhatAreAllThese"_g"Versions?
Section6.5.Review
Section6.6.WhatYouStillDon'tKnow
Section6.7.Resources
Chapter7.TheGNUCompilerforJava(gcj)
Section7.1.WhatYouWillLearn
Section7.2.ABrandGNUWay
Section7.3.TheGNUCompilerCollection
Section7.4.CompilingOurSimpleApplicationwithgcj
Section7.5.OptionsandSwitches
Section7.6.ReasonstoUsegcj
Section7.7.ReasonsNottoUsegcj
Section7.8.Review
Section7.9.WhatYouStillDon'tKnow
Section7.10.Resources
Chapter8.KnowWhatYouHave:CVS
Section8.1.WhatYouWillLearn
Section8.2.SourceControl:WhysandHows
Section8.3.AGUI:jCVS
Section8.4.Review
Section8.5.WhatYouStillDon'tKnow
Section8.6.Resources
Chapter9.Ant:AnIntroduction
Section9.1.WhatYouWillLearn
Section9.2.TheNeedforaDifferentBuildTool
Section9.3.ObtainingandInstallingAnt
Section9.4.ASampleAntBuildfile
Section9.5.Review
Section9.6.WhatYouStillDon'tKnow
Section9.7.Resources
Chapter10.IntegratedDevelopmentEnvironments
Section10.1.WhatYouWillLearn
Section10.2.NetBeans:TheOpenSourceIDE
Section10.3.SunONEStudioCommunityEdition
Section10.4.Eclipse:TheSourceofSWT
Section10.5.Review
Section10.6.WhatYouStillDon'tKnow
Section10.7.Resources
PartII:DevelopingBusinessLogic
Chapter11.BalancingActs:AnImaginaryScenario
Section11.1.WhatYouWillLearn
Section11.2.StatementoftheNeed
Section11.3.HowtoDevelopSoftware
Section11.4.WhatMakesaGoodRequirement
Section11.5.WhomtoAskforRequirements
Section11.6.RequirementsfortheBudgetApplication
Section11.7.Documenting,Prototyping,andStakeholderBuy-In
Section11.8.Review
Section11.9.WhatYouStillDon'tKnow
Section11.10.Resources
Section11.11.Exercises
Chapter12.AnalysisandDesign:SeekingtheObjects
Section12.1.WhatYouWillLearn
Section12.2.FacingtheBlankPage
Section12.3.UsingCRCCards
Section12.4.FindingtheObjects
Section12.5.FindingtheMethodsandAttributes
Section12.6.EssentialandNonessential
Section12.7.AnalysisParalysis
Section12.8.RealSoftwareEngineering
Section12.9.CoreClasses
Section12.10.Review
Section12.11.WhatYouStillDon'tKnow
Section12.12.Resources
Section12.13.Exercises
Chapter13.JUnit:AutomatingUnitTesting
Section13.1.WhatYouWillLearn
Section13.2.JUnit:WhyAlltheFuss?
Section13.3.DesignThenTestThenCode
Section13.4.InstallingandRunningJUnit
Section13.5.WritingTestCases
Section13.6.RunningTestSuites
Section13.7.Review
Section13.8.WhatYouStillDon'tKnow
Section13.9.Resources
Section13.10.Exercises
Chapter14.StoringtheData
Section14.1.WhatYouWillLearn
Section14.2.FollowtheObjects
Section14.3.OfPersistence
Section14.4.ThinkingoftheFuture,orPaintinginCorners
Section14.5.Oracle,PostgreSQL,MySQL
Section14.6.BeingSelf-Contained
Section14.7.BeyondtheBasics
Section14.8.PersistenceIsNottheWholeStory
Section14.9.SettingUpPostgreSQLforBudgetPro
Section14.10.Review
Section14.11.WhatYouStillDon'tKnow
Section14.12.Resources
Section14.13.Exercises
Chapter15.AccessingtheData:AnIntroductiontoJDBC
Section15.1.WhatYouWillLearn
Section15.2.IntroducingJDBC
Section15.3.MakingConnections
Section15.4.QueryingData
Section15.5.GettingResults
Section15.6.Updates,Inserts,Deletes
Section15.7.Review
Section15.8.WhatyouStillDon'tKnow
Section15.9.Resources
Section15.10.Exercises
PartIII:DevelopingGraphicalUserInterfaces
Chapter16.GettingintheSwingofThings:DesigningaGUIforBudgetPro
Section16.1.WhatYouWillLearn
Section16.2.ASimpleSwingProgram
Section16.3.Stompin'attheSavoy,orTheSwingParadigm
Section16.4.Slow,Slow,Quick-Quick,Slow:TheBasicSwingObjects
Section16.5.LayoutManagers
Section16.6.BeyondArthurMurray:Actions,Listeners,Events
Section16.7.GettingDowntoCases:DesigningaGUIforBudgetPro
Section16.8.Review
Section16.9.WhatYouStillDon'tKnow
Section16.10.Resources
Section16.11.Exercises
Chapter17.OtherWays:AlternativestoSwing
Section17.1.WhatYouWillLearn
Section17.2.TheIBMSWTToolkit
Section17.3.PortingBudgetProtoSWT
Section17.4.SWTandgcj
Section17.5.Review
Section17.6.WhatYouStillDon'tKnow
Section17.7.Resources
Section17.8.Exercises
PartIV:DevelopingWebInterfaces
Chapter18.Servlets:JavaPressedintoService
Section18.1.WhatYouWillLearn
Section18.2.Servlets:Program-CentricServer-SideDocuments
Section18.3.Perspective
Section18.4.HowtoWriteaServlet
Section18.5.Input,Output
Section18.6.MattersofState:Cookies,HiddenVariables,andtheDreaded
"Back"Button
Section18.7.DesigningaBudgetProServlet
Section18.8.Review
Section18.9.WhatYouStillDon'tKnow
Section18.10.Resources
Section18.11.Exercises
Chapter19.JSP:ServletsTurnedInsideOut
Section19.1.WhatYouWillLearn
Section19.2.ServletsTurnedInsideOut:JSP
Section19.3.HowtoWriteaJSPApplication
Section19.4.UsingJSPwithBudgetPro
Section19.5.Review
Section19.6.WhatYouStillDon'tKnow
Section19.7.Resources
Section19.8.Exercises
Chapter20.OpenSourceWebApplicationServers
Section20.1.WhatYouWillLearn
Section20.2.DownloadingJBoss
Section20.3.BeanEnabler,or"Let'sBeCodependent!"
Section20.4.InstallingJBoss
Section20.5.ThingsThatMakeItGo
Section20.6.DispositionofForces
Section20.7.ApacheGeronimo
Section20.8.InstallingGeronimo
Section20.9.RunningtheGeronimoServer
Section20.10.Review
Section20.11.WhatYouStillDon'tKnow
Section20.12.Resources
PartV:DevelopingEnterpriseScaleSoftware
Chapter21.IntroductiontoEnterpriseJavaBeans
Section21.1.WhatYouWillLearn
Section21.2.ExpandingtoEJBs
Section21.3.What'sinaName?AnIntroductiontoJNDI
Section21.4.Review
Section21.5.WhatYouStillDon'tKnow
Section21.6.Resources
Chapter22.BuildinganEJB
Section22.1.WhatYouWillLearn
Section22.2.EJBs:YouDon'tKnowBeans?
Section22.3.Review
Section22.4.WhatYouStillDon'tKnow
Section22.5.Resources
Chapter23.DeployingEJBs
Section23.1.WhatyouWillLearn
Section23.2.LendMeYourEAR:EnterprisePackagingandDeployment
Section23.3.DeployingtheEAR
Section23.4.MaintainingaDistributedApplication
Section23.5.AbstractingLegacyApplications
Section23.6.Review
Section23.7.WhatyouStillDon'tKnow
Section23.8.Resources
Chapter24.PartingShots
Section24.1.TheFuture'sSoBright,ISquintandLookConfused
Section24.2.OurBookIsYours
Section24.3.CametheRevolution
Section24.4.WhatYouStillDon'tKnow
Section24.5.Resources
AppendixA.ASCIIChart
AppendixB.AJavaSwingGUIforBudgetPro
AppendixC.GNUGeneralPublicLicense
Preamble
TermsandConditionsforCopying,Distribution,andModification
NoWarranty
HowtoApplytheseTermstoYourNewPrograms
Index
Copyright
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andthepublisherwas
awareofatrademarkclaim,thedesignationshavebeenprinted
withinitialcapitallettersorinallcapitals.
Theauthorsandpublisherhavetakencareinthepreparationof
thisbook,butmakenoexpressedorimpliedwarrantyofany
kindandassumenoresponsibilityforerrorsoromissions.No
liabilityisassumedforincidentalorconsequentialdamagesin
connectionwithorarisingoutoftheuseoftheinformationor
programscontainedherein.
Thepublisheroffersexcellentdiscountsonthisbookwhen
orderedinquantityforbulkpurchasesorspecialsales,which
mayincludeelectronicversionsand/orcustomcoversand
contentparticulartoyourbusiness,traininggoals,marketing
focus,andbrandinginterests.Formoreinformation,please
contact:
U.S.CorporateandGovernmentSales
(800)382-3419
ForsalesoutsidetheU.S.,pleasecontact:
InternationalSales
VisitusontheWeb:www.phptr.com
LibraryofCongressCataloging-in-PublicationData:
CIPdataonfile.
©2005PearsonEducation,Inc.
TextprintedintheUnitedStatesonrecycledpaperatPheonix
ColorinHagerstownMaryland.
Firstprinting,November2004
Dedication
Tomymother,forherloveofwords.
Michael
Tomywife,Cynthia.
Carl
BrucePeren'sOpenSourceSeries
/>JavaApplicationDevelopmentonLinux
CarlAlbingandMichaelSchwarz
C++GUIProgrammingwithQt3
JasminBlanchette,MarkSummerfield
ManagingLinuxSystemswithWebmin:System
AdministrationandModuleDevelopment
JamieCameron
UnderstandingtheLinuxVirtualMemoryManager
MelGorman
ImplementingCIFS:TheCommonInternetFileSystem
ChristopherHertel
EmbeddedSoftwareDevelopmentwitheCos
AnthonyMassa
RapidApplicationDevelopmentwithMozilla
NigelMcFarlane
TheLinuxDevelopmentPlatform:Configuring,Using,and
MaintainingaCompleteProgrammingEnvironment
RafeeqUrRehman,ChristopherPaul
IntrusionDetectionwithSNORT:AdvancedIDSTechniques
UsingSNORT,Apache,MySQL,PHP,andACID
RafeeqUrRehman
TheOfficialSamba-3HOWTOandReferenceGuide
JohnH.Terpstra,JelmerR.Vernooij,Editors
Samba-3byExample:PracticalExercisestoSuccessful
Deployment
JohnH.Terpstra
Preface
JavaandLinux
FreeSoftwareandJava
YouCanHelp!
Acknowledgments
JavaandLinux
WhyanotherbookonJava?WhyabookonJavaandLinux?
Isn'tJavaaplatform-independentsystem?Aren'tthereenough
booksonJava?Can'tIlearneverythingIneedtoknowfrom
theWeb?
Nodoubt,thereareahostofJavabooksonthemarket.We
didn'twakeuponemorningandsay,"Youknowwhattheworld
reallyneeds?AnotherbookaboutJava!"No.Whatwerealized
wasthatthereareacoupleof"holes"intheJavabookmarket.
First,Linuxasadevelopmentplatformanddeployment
platformforJavaapplicationshasbeenlargelyignored.Thisis
despitethefactthatthe*nixplatform(meaningallUNIXand
UNIX-likesystems,Linuxincluded)haslongbeenrecognizedas
oneofthemostprogrammer-friendlyplatformsinexistence.
ThosefewresourcesforJavaonLinuxthatexistemphasize
toolstotheexclusionoftheJavalanguageandAPIs.
Second,booksontheJavalanguageandAPIshavefocusedon
pedagogicalexamplesthatservetoillustratethedetailsofthe
languageanditslibraries,butveryfewoftheseexamplesarein
themselvespracticallyuseful,andtheytendtodealonlywith
theissuesofwritingprograms,andnotatallwithdeploying
andmaintainingthem.Anyonewhohasworkedonamajor
softwareproject,especiallyasoftwareprojectthatisdeveloped
anddeployedinabusinessforabusiness,knowsthatdesigning
andcodingareonlyabouthalfoftheworkinvolved.Yes,writing
Javacodeisonlyslightlyaffectedbythedevelopmentandthe
deploymentplatform,buttheprocessofreleasingand
maintainingsuchapplicationsissignificantlydifferentbetween
platforms.
Toaddressthesemissingpieces,wedecidedtocover
developmentanddeploymentofaJavaapplicationthathas
command-line,GUI,servlet,andenterprisecomponentsona
Linuxplatform.We'rewritingtheguidebookwewishwehad
hadwhenwestartedwritinganddeployingJavaapplicationson
Linux.We'regoingtoshowyouasimplisticenterprise
application,"fromcradletograve,"butalongthewaycover
issuesofdesignprocess,productionenvironment,setup,
administration,andmaintenancethatfewbooksbotherto
cover.[1]
[1]Thisisnottosaythisbookiswithoutpurelypedagogicalexamples.EspeciallyinPartIwemakeuseofyour
typical"throwaway"examplesandsingleclasses.Totrytoillustratethebasicswithacompleteapplication
wouldobscureandconfusethepointsbeingillustrated.
Ifyouareconsideringbuyingthisbookandyouarewondering
ifthereisanyinformationinherethatyoucan'tgetforfreeon
theWeb,then,no.Thereisnot.Infact,thereislittle
informationinanyJavaorLinuxbookthatisnotavailablefor
freeontheInternet.Infact,ineachofourchapterswewilltell
youwhereontheWebtofindvirtuallyalloftheinformationwe
present,andthensome.Andyetbookscontinuetosell,andwe
havethechutzpahtoaskyoutobuythebook.Thereasonis
thatWebinformationisscattered,unorganized,andofhighly
variablequality.Wewillbetryingtobringalltherelevant
informationtogetherinthisbook,inaclearlyorganizedmanner
(and,wewouldliketobelieve,atanacceptablyhighlevelof
quality).Wethinkthathasvalue.
Also,thisbookispartoftheBrucePerens'OpenSourceSeries.
ThisbookispartoftheWebliterature.Andyoumayfreelyread
itanduseitontheWeb.Wehopethisbookwillbeoneofthose
youuseontheWebandbuyonpaper.Wedon'tknowabout
you,butweliketouseWebbooksforreference,butfor
reading,welikebooks.Weownatleastthreebooksthatare
availableforfreeontheWeb:ThinkinginC++,Thinkingin
Java,andO'Reilly'sDocbook:TheDefinitiveGuide.Wehope
thatopenpublishingwillbethenewmodel.
FreeSoftwareandJava
GNU/Linux[2]isFreeSoftware.ItisOpenSource.Idon'teven
wanttostartthedebateonwhateachtermmeansandwhich
oneis"right."OneofthetwoauthorsofthisbookisaFree
Softwareadvocate,andtheotherisofapurelylaissez-faire
attitudetowardsthequestion(wewon'ttellyouwhich,
althoughweinviteyoutoguess).Butevenwithadeliberate
decisiontocease-fire,thequestionremains:IsJavaOpen
SourceorFreeSoftware?
[2]Thisistheonlytimewewillrefertoitas"GNU/Linux."SeeSection7.3forthestoryofwhyGNU/Linuxisthe
preferrednameofsome.WeunderstandStallmanandtheFSF'sposition,but"Linux"ismucheasieronthe
eyesandearsthan"GNU/Linux."Andthat,notprinciple,ishownamesandwordsgointothelanguage.For
betterorforworse,"Linux"isthenameoftheoperatingsystem.
Theanswerismixed.NeitherSun'snorIBM'sJava
implementationsareOpenSourceorFreeSoftware.Youmay
downloadandusethemforfree,butyoudonothavethe
sourcecodetothem,nordoyouhavetherighttomake
modificationstothem.[3]ThisbookwillcovertheGNUCompiler
forJava,whichcompilesJavasourcecodetonativemachine
code.TheGNUCompilerforJava(gcj)isbothOpenSourceand
FreeSoftware.Itis,however,supportingdifferinglevelsofthe
JavaAPIs(somepackagesarecurrent,somearebackat1.1.x
levels)anddoesnotfullysupporttheAWTorSwingGUIs.
[3]Aswewritethis,averypublicdiscussionistakingplacebetweenSun,IBM,andEricRaymond,founderof
theOpenSourceInitiative,aboutopeningJavaundersomesortofopensourcelicense.Atthistime,noone
knowshowthiswillturnout,butitispossiblethatJavawillbeFreeSoftwareinthefuture.
However,noneofthismeansthatyoucannotwriteyourown
JavaprogramsandreleasethemunderaFreeSoftwareorOpen
Sourcelicense.SoyoucancertainlydevelopFreeSoftwarein
Java.StaunchFreeSoftwarepartisans(suchasRichard
StallmanandtheFreeSoftwareFoundation)wouldquestionthe
wisdomofdoingso.TheirargumentwouldbethataFree
Softwareproductthatdependsonnon-Freetoolsisn'treally
FreeSoftware,sincetocompile,use,ormodifyit,youneedto
makeuseofaproprietarytool.
ThereismorethanoneefforttoproduceaFreeSoftwareJava
runtimeimplementation.Noneofthemis"readyforprime
time."Itwould,inouropinion,beaverygoodthingforSunto
releasetheirSDKandJavaVirtualMachineasFreeSoftware.
Butsofar,theyhavesteadilyresistedcallstodoso.
Thefact,however,thattwodistinctvendors(SunandIBM)
produceeffectivelyinterchangeabledevelopmentandruntime
environmentsreducessomeoftheriskthatyoufacewhenyou
selectaplatformavailableonlyfromasinglevendorwhodoes
notprovidesourcecode.
So,toputthecasefirmly:Javaisfreeforuse,butitiscertainly
notFreeSoftwareasdefinedinTheGNUManifesto[4]orthe
GNUGeneralPublicLicense.[5]Thisisapoliticaland
philosophicalissueofinterestonlytothoseaforementioned
FreeSoftwarepartisans.Fortherestofus,thishasnobearing
onJava'stechnicalorbusinessmerits.Asforus,obviouslywe
likethelanguageorwewouldn'tbewritingaboutit.
[4] />
[5] />
YouCanHelp!
ThisbookispartoftheBrucePerens'OpenSourceSeries.
Shortlyafterthisbookispublishedindead-treeform,itwillbe
ontheWeb,[6]freeforuse,redistribution,andmodificationin
compliancewiththetermsoftheOpenPublicationLicense,[7]
withnooptionstaken.Youcanimmediatelycreateyourown
versionaspermittedinthatlicense.
[6] />
[7] />
Naturallyenough,weplantomaintainour"official"versionof
theonlinebook,soweencourageyoutosendsuggestions,
corrections,extensions,comments,andideastous.Please
sendanysuchtoandwewilltryto
keepourlittletomeup-to-datesoitcontinuestoservethe
needsoftheJavaandLinuxdevelopmentcommunities.
Acknowledgments
Firstoff,wenaturallywishtothankMarkL.Taub,our
acquisitionseditoratPrenticeHallPTR,forbelievinginthebook
andinopenpublishingasthewaytoputitoutthere.Wealso
wanttothankBrucePerensforlendinghisnameandpowersof
persuasiontoopen-contentpublishingthroughthePrenticeHall
PTRBrucePeren'sOpenSourceSeries.Thanks,too,toPatrick
Cash-PetersonandTyrrellAlbaugh,whoworkedasourin-house
productioncontacts,forallthebehind-the-scenesworkthey
did,includingoverseeingthecover.
Inmoredirecttermsofcontent,weowemajorthankstoKirk
VogenofIBMConsultinginMinneapolisforhisarticleonusing
SWTwithgcj,andforhiskindhelpinallowingustousethe
ideashefirstpresentedinhisIBMdeveloperWorksarticles.In
moredirecttermsofcontent,weowemajorthanksto:Kirk
VogenofIBMConsultinginMinneapolisforhisarticleonusing
SWTwithgcj,andforhiskindhelpinallowingustouseideas
hefirstpresentedinhisIBMdeveloperWorksarticles;andto
DeepakKumar[8]forgraciouslyallowingustobaseour
build.xmlfileforEJBsoffofaversionthathewrote.
[8] />
Thanks,too,toAndrewAlbingforhishelpindrawingsomeof
ourdiagrams,andtoGeorgeLogajanandtoAndyMillerfor
sharingtheirinsightsonthemoreintricatedetailsofSwing.
Wealsowishtoexpressourgreatindebtednesstoourtechnical
reviewers,especiallyAndrewHayes,SteveHuseth,andDan
Moore.AverylargethankyouisalsoduetoAlinaKirsanova
whoseeyefordetail,endlesspatience,andtenacity,andoverall
talentwithproofing,layout,andmoreaddedsomuch
refinementandimprovementtothebook.Wearegreatfulfor
alltheircontributions.Anyerrorsoromissionsinthistextare
ourfaultandcertainlynottheirs.Thebookismuchstrongerfor
alltheirefforts.
Therearelikelymanymorepeopleweoughttothank,
especiallythoseatPrenticeHallPTR,whosenamesand
contributionswemayneverknow,butwedoknowthatthiswas
aneffortofmanymorepeoplethanjusttheauthors,andwe
aregratefultothemall.
Introduction
Thisbookhastheunfortunateburdenofservingadiversesetof
audiences.Werealizethatthisbookmightappealtoboth
experiencedJavaprogrammerswhoarenewtoLinux,andto
experiencedLinuxprogrammerswhoarenewtoJava,withall
possibleshadingsinbetween.
Inadditiontobalancingthesetwopoles,wearealsotryingto
strikeabalancebetweenthesizeofthebookandtherangeof
ourtopic.Fortunately,thereistodayquitearangeofbothbook
andWebpublishingonbothJavaandLinux,soweareableto
doourbestwithinthelimitsofabookanormalpersonmaylift,
andwecanmakerecoursetoanumberofoutsidereferences
youmightwishtousetosupplementourefforts.
WhoShouldBuyThisBook
IfyouareanexperiencedJavaprogrammer,butquitenewto
Linux,andyouhavebeenlookingforinformationonthetools
availabletodevelopanddeployJavaapplicationsonLinux
systems,thisbookwillprovidealotofusefulinformation.
IfyouareanexperiencedLinuxuserordeveloper,andyouare
interestedinusingtheJavalanguageonthatplatform,this
bookwillguideyouthroughsomeadvancedJavadevelopment
topicsandwillpresent,wehope,somenovelusesforfamiliar
LinuxandGNUtools.
IfyouarearankbeginnertoeitherLinuxorJava,westillthink
thisbookhasvalue,butwewouldrecommendthatyouuseitin
conjunctionwithmoreintroductorybooks.Forabasic
introductiontoJavaandobject-orientedprogramming,we
recommendBruceEckel'sexcellentbook,ThinkinginJava
(ISBN0-13-100287-2).ForanintroductiontoLinuxandits
tools,wecanrecommendTheLinuxBookbyDavidElboth
(ISBN0-13-032765-4)[1]asanall-aroundtitle.Wealsolist
severalotherbooksinsectionstitledResourcesthroughoutthis
book.ManybookswerecommendarenotactuallyLinuxspecific.SinceLinuxduplicates(inmostrespects)aUNIX
platform,wedooccasionallyrecommendbooksthataregeneral
toall*nixsystems.
[1]NotethatwedotendtorecommendtitlesfromPearsonEducation(ourpublishers),butthatwebynomeans
confineourselvestothatpublisher.
Ifyouareadeveloper,contractor,orMISdevelopmentmanager
withmoreprojectsthanbudget,ourbookwillintroduceyouto
manysolidtoolsthatarefreeoflicensefeesforthe
developmentanddeploymentofproductionJavaapplications.
Weareallbeingaskedtodomorewithlessallthetime.In
many(butcertainlynotall)cases,FreeandOpenSource
softwareisanexcellentwaytodothat.
WhoShouldNotBuyThisBook
ThoselookingforcompletedocumentationonJavaAPIsand
Linux-basedJavaapplicationserverswillbedisappointed.
CompletereferencematerialonFreeSoftwareandOpenSource
Softwaremaybefoundinbookform,butitismostcertainly
out-of-date.Andwhilethisisanopen-contentbook,weknow
fullwellthatwewillonlybeupdatingitasour"dayjobs"
permit.Inotherwords,thoseseekingcompleteandcurrent
referencematerialshouldgototheWeb.
Thosewhohaveamultimillion-dollarbudgetforapplications
developmentwillprobablybewellservedbycommercial
applicationserverproducts.Whileweverymuchbelievethat
LinuxandJavaonLinuxarefullycapableofsupporting
productionenvironments,werecognizethatproductssuchas
BEAWeblogicandIBM'sWebSpherehavelargesupport
organizationsbehindthem,and(atleastfornow)alargerbase
ofdevelopersandcontractingorganizationswithstaff(variably)
experiencedinwritingandsupportingapplicationsinthese
environments.Pleasenotethatyoucanruntheseproductson
Linuxsystems,andthattheyarepartoftheLinux-Javaworld.
Ourbookdoesnotcoverthem,however,bothbecausetheyare
well-coveredelsewhere,andbecausewehavechosento
emphasizetheFreeandOpenSourcetoolsmerelytokeepthe
booksmallenoughtolift,whilestillcoveringthosetoolsmostin
needofwell-writtensupportingdocumentation.