Professional Documents
Culture Documents
JavainEmbeddedLinuxSystems
ThomasPetazzoni/MichaelOpdenacker FreeElectrons http://freeelectrons.com/
CreatedwithOpenOffice.org2.x
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
Rightstocopy
Copyright20042008 FreeElectrons feedback@freeelectrons.com Documentsources,updatesandtranslations: http://freeelectrons.com/articles/java Corrections,suggestions,contributionsand translationsarewelcome!
AttributionShareAlike2.5 Youarefree tocopy,distribute,display,andperformthework tomakederivativeworks tomakecommercialuseofthework Underthefollowingconditions Attribution.Youmustgivetheoriginalauthorcredit. ShareAlike.Ifyoualter,transform,orbuilduponthiswork, youmaydistributetheresultingworkonlyunderalicense identicaltothisone. Foranyreuseordistribution,youmustmakecleartoothersthe licensetermsofthiswork. Anyoftheseconditionscanbewaivedifyougetpermissionfrom thecopyrightholder. Yourfairuseandotherrightsareinnowayaffectedbytheabove. Licensetext:http://creativecommons.org/licenses/bysa/2.5/legalcode
Sep15,2009
Bestviewedwith...
ThisdocumentisbestviewedwitharecentPDFreader orwithOpenOffice.orgitself! Takeadvantageofinternalorexternalhyperlinks. So,donthesitatetoclickonthem! Findpagesquicklythankstoautomaticsearch Usethumbnailstonavigateinthedocumentinaquickway IfyourereadingapaperorHTMLcopy,youshouldgetyour copyinPDForOpenOffice.orgformaton http://freeelectrons.com/articles/java!
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
Contents
Javahistory Keyconceptsandfeatures IssueswithJava Java'sstrengthsfor embeddedsystems Glossary Javaimplementations JVMimplementations Javahardware accelerationandLinux Conclusion Usefulreading
Sep15,2009
Javahistory(1)
1991:Sunstartedworkingonaprojecttoanticipatethenextwave ofcomputing:theconvergenceofdigitallycontrolledconsumer devicesandcomputers. 1992:Implementedhomeentertainmentcontroldemoswitha processorindependentlanguage:Oak. 19921994:focusmovingfromdigitalcabletelevisionnetworkto theInternetasawaytopublishandsharecontent. 1994:OakrenamedasJava. 1994:HotJavawebbrowserwithdynamic,executablecontent. 1995:FirstpublicreleaseofJava.Greatsuccess.
Sep15,2009
Javahistory(2)
1995:NetscapeannouncedsupportforJava. 1996:Java1.0release. 1996:MicrosofttakesaJavalicense. 19972001:SunsuesMicrosoftfortryingviolatingitslicenseandtrying toenforceitsownJavastandard. 2001:MicrosoftlosestherighttoadvertiseitsproductsasJava Compatible.Microsoft'slicensedterminatedbutcancontinuetouseits ownimplementations. 1998:Java1.2.RenamedasJava2 2006:SunannouncesthereleaseofJavaundertheGPLLicense. JavaisFree!
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
Javakeyconcepts
WORE WriteOnce,RunEverywhere JavaapplicationsarecompiledinJavaVirtualMachine(JVM) bytecode.CanberunonanyplatformwithaJVMimplementation.
Java sourcecode
Java Compiler
JVM binary
Developer environment
JVM binary
JVM Interpreter
User environment
Sep15,2009
Javafeatures
Seehttp://java.sun.com/docs/overviews/java/javaoverview1.htmlfordetails
Simple
Automaticgarbagecollection,smallfootprint Objectoriented Forwelldefined,reusableswcomponents NetworkSavvy Supportfornetworkprotocols(http,ftp...) Robust Nopointers,nomemorycorruption,true arrays.Strictcompileandruntimechecking. Secure Builtforsecurityinnetworkingenvironments. Dataprotection(nopointers). Architectureneutral CoderunsanywhereaVMisavailable Portable Noarchitecturedependentdatasizes(int:32bit, float:32bit).PortableVMsourceCcode. Interpreted Ontheflyconversiontonativemachinecode Highperformance VMcodedesignedforsimplemachinecode generation.Optimizedbytecodegeneratedbythe compiler.VMinterpreteroptimizations. Multithreaded Multithreadsupportinthelanguageitself.But RealtimeperformancelimitedbyOSRTperf. Dynamic Upgradingaclassdoesn'tforcetorecompilethe applicationsusingit.
Sep15,2009
JNI:JavaNativeInterface
Helpstounderstandhowyoucanaccessthehardware withtheJVM! TheJNIletscoderunningontheJVMoperatewith applicationsandlibrarieswritteninotherlanguagessuch asC,C++orassembly. Neededtousesystemdependentroutineshandling hardwareaccess.
Sep15,2009
Java'sstrengthsinembeddedsystems
HidesthespecificitiesofthedeviceandtheembeddedOS ProvidesanumberoffeaturesbeyondthoseofferedbytheOS Allowstobuildnetworkinteroperableembeddedsystems,whatever theirhardwarearchitecture. Simplifiesproductdevelopment.Thesoftwarecaneasilybedeveloped onworkstationsinparallelwiththehardware. Makesitpossibletoreusecode EasyintegrationofJavaCodeandnativecode Smallerapplicationsfootprint:morecompactbytecodeandhigherlevel classavailability.
Sep15,2009
10
SunJavaplatforms
Sundefined3platformstargetingdifferentapplication environments JavaPlatformMicroEdition(JavaME), forenvironmentswithlimitedresources JavaPlatformStandardEdition(JavaSE),for workstationenvironments.Theversioneveryoneuseson hisworkstationtorunJavaapplicationsorapplets JavaPlatformEnterpriseEdition(JavaEE),forlarge distributedenterpriseorInternetenvironments
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
11
Javaterminology
TorunJavaapplications,aJREisrequired JavaRuntimeEnvironment ComposedofaJVM,JavaVirtualMachine, whichexecutesthebytecode AndofanimplementationofallstandardJavaclasses TodevelopJavaapplications,aJDKisneeded JavaDevelopmentKit ComposedofaJREanddevelopmenttools suchastheJavacompiler
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
12
JavaME
JavaMEspecifiestwoconfigurations,withdifferentsetofclassesandAPIs ConnectedLimitedDeviceConfiguration,thesmallestpossibleJava configurationforembeddeddevicessuchasphones. ConnectedDeviceConfiguration,amuchmorefeaturefulconfigurationfor largerembeddeddevicessuchashighendPDAs,settopboxes,etc. Eachconfigurationexistsindifferentprofiles definingexactlywhatfeaturesareavailable. Sunprovidesareferenceimplementation, butthirdpartiesoftenhavetheirownimplementation.
Sep15,2009
13
ImplementationsfromSun
ImplementationsoriginatingfromSun
Sep15,2009
14
Sun'simplementationofJavaSE
SunimplementationofJavausedtobeclosedsource Officialreasonwasthefearofincompatibleforksthatwould breaktheuniformityoftheJavaplatform. In2006,SunopenedthesourcecodeofitsJavaSEimplementation underGPLversion2. TheversionavailabletodayforLinux,WindowsandSolaris,both x86andx86_64. SomepiecesofcodecouldnotbereleasedundertheGPL,because Sunwasnotthefullownerofthecopyright.Sunstartedthe OpenJDKprojecttoreplacethesepartswithopensourceversions.
Sep15,2009
15
JavaSEforembedded
WiththeincreasinglyfastCPUsandgrowingamountofmemory foundinembeddedsystems,SunisnowadverstisingJavaSEfor embeddedsystems. Suitableifyouhavemorethan32MBofmemoryandstorage, otherwiseonlyJavaMEissuitable. AvailableforARM,MIPSandPowerPC.Headlessversions available,reducedfootprintoftheJRE. However,theseversionsarenotreleasedundertheGPL,and subjecttoroyaltieswhendistributed. http://java.sun.com/javase/embedded/
Sep15,2009
16
OpenJDK(1)
http://openjdk.java.net/ ProjectstartedbySunafteropensourcingJavainNovember2006 Goal:tocollaborateonanopensourceimplementationofthe JavaPlatform,StandardEditionandrelatedprojects Encumberedparts:audioengine,cryptographiccode,font rasterizer,colormanagement,etc. InJune2007,RedHatstartedtheIcedTeaprojecttocreate experimentalpatchestoreplacethesepartsandwasshipping IcedTeainitsdistribution. Seehttp://en.wikipedia.org/wiki/IcedTea
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
17
OpenJDK(2)
November2007,RedHatjoinsOpenJDK. December2007,JavasourcecodemovedtoMercurial. February2008,firstread/writeaccesstotherepositorytonon Sunengineers. February2008,OpenJDK6createdtoquicklyhaveafullyOpen Sourceimplementationwithasfewdifferencesaspossible. ThisversionisnowshippedinUbuntu8.04,Fedora9andRed HatEntrepriseLinux5. http://www.sun.com/software/opensource/java/faq.jsp
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
18
OpenJDKlicense
OpenJDKisreleasedundertheGNUGeneralPublic Licenseversion2,withClasspathexception. TheClasspathexceptionhasbeendesignedfortheGNU Classpathproject(coveredlater). Itallowstocreateanddistributeproprietaryapplications ontopoffreeimplementationsofJava. http://www.sun.com/software/opensource/java/faq.jsp#g
Sep15,2009
19
PhoneME
https://phoneme.dev.java.net/ ProjectcreatedafteropensourcingSunimplementationofJavaME Twoversions PhoneMEfeaturesoftware(CLDC),formobilephones PhoneMEadvancedsoftware(CDC),forhigherenddevices Referenceimplementationsavailableforx86,ARMandMIPS. Portingtootherplatformsandarchitecturessaidtobeeasy. JavastillsellsitscommercialversionofJavaME
Sep15,2009
20
IndependentJ2SEimplementations
IndependentJ2SEimplementations
Sep15,2009
21
Components(1)
AusableimplementationofJavaismadeofseveral importantcomponents AJavacompiler,eithertomachineorbytecode AvirtualmachinecapableofexecutingtheJava bytecode TheclasslibraryimplementingallstandardJavaclasses andmethods
Sep15,2009
22
Components(2)
Developingavirtualmachineisinteresting,alotofinnovation andresearchispossible
Lotsofdifferentprojectsavailable
Developingtheclasslibraryisnotreallyinteresting,verylong andprobablyboring
Onlyoneusableproject:GNUClasspath
Thevirtualmachineandclasslibraryarenotindependent: someintegrationbetweenthemisneeded
http://wiki.debian.org/Java/DevJam/2008/Fosdem?action=AttachFile&do=get&target=fosdem2008vminterfaces.pdf
Sep15,2009
23
GNUClasspath
http://www.gnu.org/software/classpath/ JavaclassesimplementationfromtheGNUproject License:GNUGPL,whichanexceptionforlinkingwiththis library.So,nolicenseissuewithproprietaryJavaprograms. ExhaustiveJavaAPIimplementation,abletorunapplications suchasEclipse. GraphicalapplicationsrelyonGTKorQt. Activeproject.
Sep15,2009
24
GNUcompilerforJava
http://gcc.gnu.org/java/
gcjcancompile:
Javasourcecodedirectlytonative machinecode JavasourcecodetoJavabytecode (classfiles) Javabytecodetonativemachine code.
libgcj:runtimeforgcj compiledapplications
coreclasslibraries garbagecollector bytecodeinterpreter
Sep15,2009
25
Usinggcj:sampleprogram
Sep15,2009
26
Usinggcj:nativecode
$gcjHello.javamain=Helloohello $filehello $./hello HelloWorld $lddhello [...] libgcj.so.90=>/usr/lib/libgcj.so.90(0xb5f5c000) [...] On a Debian system, libgcj.so takes ~32 MB.
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
hello:ELF32bitLSBexecutable,Intel80386,version1(SYSV),for GNU/Linux2.6.8,dynamicallylinked(usessharedlibs),notstripped
Sep15,2009
27
Usinggcj:bytecode
Compiling $gcjHello.javaC $lsHello.* Hello.classHello.java Executing with gij and Sun's JVM $gijHello HelloWorld $javaHello HelloWorld
Sep15,2009
28
Othercompilers
Jikes
InitiallycreatedbyIBM,nowacommunityproject http://jikes.sourceforge.net
Eclipsecompiler
IncrementalcompilerusedinEclipse Nowusedforparsingbygcj,sincegcc4.3(March2008),in ordertosupportthelatestadditionsofJava1.5suchasgenerics http://www.eclipse.org/jdt/core/
Sep15,2009
29
Kaffe
http://www.kaffe.org/ CleanroomJVMimplementationplusassociatedclasslibrariesneededbyaJava runtimeenvironment,takenfromtheGNUClasspathproject NotanofficiallylicensedJVMimplementation. NotfullycompatiblewithJavaspecsandlackssomekeyfeatures(security,etc.) Supportedinseveralplatforms:x86,arm,mips,m68k,ppc... GreatforVMeducationorresearch,orinaFreeSoftwareJavadistribution. Untilversion1.1.9,KaffehasadditionalgraphicalbackendsoverClasspathbut theywillbedroppedinfutureversions License:GNUGeneralPublicLicense
Sep15,2009
30
JikesRVM
http://oss.software.ibm.com/developerworks/opensource/jikesrvm/ RVM:ResearchVirtualMachine OpenSource(CommonPublicLicense)implementationfrom IBM ImplementedonJava,runningonitselfwithoutrequiringasecond virtualmachine SupportedLinuxPlatforms: x86andPowerPC ReliesonGNUClasspath.
Sep15,2009
31
SableVM
http://sablevm.org/ Arobust,clean,easytomaintainandextend,extremelyportable, efficient,andspecificationcompliantJavavirtualmachine CleanroomJVMimplementation RoughlysupportedonmostarchitecturessupportedbyLinux (ARMinparticular) CompatiblewithJVMandJavaLanguagespecifications License:GNULesserGeneralPublicLicense UsesGNUClasspath(GPLwithanexceptionforlinking)
Sep15,2009
32
JamVM
http://jamvm.sourceforge.net/ AcompactVirtualMachine Verycompact:~200KBonPowerPC,180KBonx86 Fullfeatured,conformingtothespecifications,contrarytoother lightweightJVMs Activelydeveloped AvailableforLinuxonPowerPC,x86,ARM,x86_64andMIPS DesignedtoworkwithGNUClasspath
Sep15,2009
33
Cacao
http://www.cacaojvm.org/ AnotherVirtualMachineusingJIT WorksonARM,MIPS,PowerPC,x86,x86_64 CanuseeitherGNUClasspath,OpenJDKorPhoneME asaJavaruntimelibrary. PackagesnowavailableinDebianunstable.
Sep15,2009
34
IBM'sJavaonLinux
http://www106.ibm.com/developerworks/java/jdk/linux140/ CompleteimplementationfromIBM: J2SE,J2EE,J2ME,includingIBM'sVM. SupportedLinuxplatforms(onlyin32bitmode) IA32,AMD64,Itanium,PowerPC64bit,zSeries IBM'simplementations ReengineeredJavaMachine,IBM'sJustInTimecompiler... JavaisatthecoreofIBM'sstrategy(WebSphereinparticular)
Sep15,2009
35
IndependentJ2MEimplementations
IndependentJ2MEimplementations
Sep15,2009
36
J2MEimplementations
MIDPath JavalibrarythatprovidesaMIDP2implementation,alternativetothe referenceimplementationofPhoneME.Canbeusedtogetherwiththe CLDCversionofCacaoVM. MIDP2isaspecificprofileofCLDCfoundonmanyphones http://midpath.thenesis.org/ Microemu J2MEemulatorthatrunsontopofJ2SE PurelyimplementedinJava http://www.microemu.org/
JavainEmbeddedLinuxSystems Copyright20042007,FreeElectrons, CreativeCommonsAttributionShareAlike2.5license http://freeelectrons.com
Sep15,2009
37
JavahardwareaccelerationinLinux
SomeARMcoresdirectlysupportJavabytecodeexecution(Jazelletechnology): http://www.arm.com/products/multimedia/java/jazelle.html Theprocessorcandirectlyexecute~120Javabytecodeinstructions,and generateanexceptionfortherestsothattheexecutionofthebytecodecanbe emulated. Unfortunately,ARMdoesn'tpublishthespecificationsofthistechnology OnlylicenseescangetinformationaboutJazelle Sun'sJVMareJazelleaware,butthroughabinaryonlycomponent Somereverseengineeringisinprogress.
Sep15,2009
38
Conclusion
Javahasgreatcompetitiveadvantagesfordeveloping applicationsforoperatingsystems. FreeSoftwareimplementationsforGNU/Linuxare availablenowandsatisfymostneeds.
Sep15,2009
39
Usefulreading
EmbeddedJava+Linuxreference:
http://www.linuxdevices.com/articles/AT8918758707.html
Javaoverviewandhistory:
http://en.wikipedia.org/wiki/Java_programming_language
Sep15,2009
40
Relateddocuments
AllthetechnicalpresentationsandtrainingmaterialscreatedandusedbyFreeElectrons, availableunderafreedocumentationlicense(morethan1500pages!). http://freeelectrons.com/training
IntroductiontoUnixandGNU/Linux EmbeddedLinuxkernelanddriverdevelopment FreeSoftwaretoolsforembeddedLinuxsystems AudioinembeddedLinuxsystems MultimediainembeddedLinuxsystems LinuxUSBdrivers RealtimeinembeddedLinuxsystems IntroductiontouClinux LinuxonTIOMAPprocessors FreeSoftwaredevelopmenttools JavainembeddedLinuxsystems IntroductiontoGNU/LinuxandFreeSoftware Linuxandecology What'snewinLinux2.6? HowtoportLinuxonanewPDA
http://freeelectrons.com/articles
AdvantagesofFreeSoftwareinembeddedsystems EmbeddedLinuxoptimizations EmbeddedLinuxfromScratch...in40min!
Sep15,2009
41
Howtohelp
Ifyousupportthiswork,youcanhelp... Bysendingcorrections,suggestions,contributionsandtranslations Byaskingyourorganizationtoordertrainingsessionsperformedby theauthorofthesedocuments(seehttp://freeelectrons.com/training) Byspeakingaboutittoyourfriends,colleagues andlocalFreeSoftwarecommunity. Byaddinglinkstoouronlinematerialsonyourwebsite, toincreasetheirvisibilityinsearchengineresults.
Sep15,2009
42
EmbeddedLinuxTraining UnixandGNU/Linuxbasics Linuxkernelanddriversdevelopment RealtimeLinux uClinux Developmentandprofilingtools Lightweighttoolsforembeddedsystems Rootfilesystemcreation Audioandmultimedia Systemoptimization
FreeElectronsservices
CustomDevelopment Systemintegration EmbeddedLinuxdemosandprototypes Systemoptimization Linuxkerneldrivers Applicationandinterfacedevelopment
http://freeelectrons.com
Relateddocuments
Howtohelp
Youcanhelpustoimproveandmaintainthisdocument... Bysendingcorrections,suggestions,contributionsand translations Byaskingyourorganizationtoorderdevelopment,consulting andtrainingservicesperformedbytheauthorsofthese documents(seehttp://freeelectrons.com/). Bysharingthisdocumentwithyourfriends,colleagues andwiththelocalFreeSoftwarecommunity. Byaddinglinksonyourwebsitetoouronlinematerials, toincreasetheirvisibilityinsearchengineresults.
FreeElectrons.Kernel,driversandembeddedLinuxdevelopment,consulting,trainingandsupport.http//freeelectrons.com
Linuxkernel Linuxdevicedrivers Boardsupportcode Mainstreamingkernelcode Kerneldebugging EmbeddedLinuxTraining Allmaterialsreleasedwithafreelicense! UnixandGNU/Linuxbasics Linuxkernelanddriversdevelopment RealtimeLinux,uClinux Developmentandprofilingtools Lightweighttoolsforembeddedsystems Rootfilesystemcreation Audioandmultimedia Systemoptimization
FreeElectrons
Ourservices
CustomDevelopment Systemintegration EmbeddedLinuxdemosandprototypes Systemoptimization Applicationandinterfacedevelopment Consultingandtechnicalsupport Helpindecisionmaking Systemarchitecture Systemdesignandperformancereview Developmenttoolandapplicationsupport Investigatingissuesandfixingtoolbugs