Vous êtes sur la page 1sur 7

10/3/2014 History of Java programming language | www.freejavaguide.

com
http://www.freejavaguide.com/history.html 1/7
HistoryofJavaprogramminglanguagefreejavaguide.com
JavaisanobjectorientedprogramminglanguagedevelopedbyJamesGoslingand
colleaguesatSunMicrosystemsintheearly1990s.Unlikeconventionallanguageswhich
aregenerallydesignedeithertobecompiledtonative(machine)code,ortobeinterpreted
fromsourcecodeatruntime,Javaisintendedtobecompiledtoabytecode,whichisthen
run(generallyusingJITcompilation)byaJavaVirtualMachine.
ThelanguageitselfborrowsmuchsyntaxfromCandC++buthasasimplerobjectmodel
andfewerlowlevelfacilities.JavaisonlydistantlyrelatedtoJavaScript,thoughtheyhave
similarnamesandshareaClikesyntax.
History
Javawasstartedasaprojectcalled"Oak"byJamesGoslinginJune1991.Gosling'sgoals
weretoimplementavirtualmachineandalanguagethathadafamiliarClikenotationbut
withgreateruniformityandsimplicitythanC/C++.ThefirstpublicimplementationwasJava
1.0in1995.Itmadethepromiseof"WriteOnce,RunAnywhere",withfreeruntimeson
popularplatforms.Itwasfairlysecureanditssecuritywasconfigurable,allowingfornetwork
andfileaccesstobelimited.Themajorwebbrowserssoonincorporateditintotheirstandard
configurationsinasecure"applet"configuration.popularquickly.Newversionsforlargeand
smallplatforms(J2EEandJ2ME)soonweredesignedwiththeadventof"Java2".Sunhas
notannouncedanyplansfora"Java3".
In1997,SunapproachedtheISO/IECJTC1standardsbodyandlatertheEcmaInternational
toformalizeJava,butitsoonwithdrewfromtheprocess.Javaremainsaproprietarydefacto
standardthatiscontrolledthroughtheJavaCommunityProcess.Sunmakesmostofits
Javaimplementationsavailablewithoutcharge,withrevenuebeinggeneratedbyspecialized
productssuchastheJavaEnterpriseSystem.SundistinguishesbetweenitsSoftware
DevelopmentKit(SDK)andRuntimeEnvironment(JRE)whichisasubsetoftheSDK,the
primarydistinctionbeingthatintheJREthecompilerisnotpresent.
Philosophy
TherewerefiveprimarygoalsinthecreationoftheJavalanguage:
1.Itshouldusetheobjectorientedprogrammingmethodology.
2.Itshouldallowthesameprogramtobeexecutedonmultipleoperatingsystems.
3.Itshouldcontainbuiltinsupportforusingcomputernetworks.
4.Itshouldbedesignedtoexecutecodefromremotesourcessecurely.
5.Itshouldbeeasytousebyselectingwhatwasconsideredthegoodpartsofotherobject
orientedlanguages.
Toachievethegoalsofnetworkingsupportandremotecodeexecution,Javaprogrammers
sometimesfinditnecessarytouseextensionssuchasCORBA,InternetCommunications
Engine,orOSGi.
Objectorientation
FreeJavaGuide
ProgrammingTutorials
HistoryofJava
FreeJAVATutorials
SCJPNotes1
SCJPNotes2
SCJPNotes3
SCJPNotes4
SCJPNotes5
SCJPNotes6
SCJPNotes7
SCJPNotes8
JavaTest
JDBCProgramTutorial
JavaSwing
JavaSourceCode
JavaApplet
JavaServlet
JavaServerPages
CriticismofJava
SQLTutorial
PLSQLTutorial
PLSQLExamples
HTMLTutorial
WhatisXML?
XMLTutorial
JobInterviewQuestions
JavaInterview
SQLInterview
XMLInterview
HTMLInterview
Partnerwebsites
BirdWatching
HaryanaOnline
AsiaNewscast
NorthIndiaOnline
10/3/2014 History of Java programming language | www.freejavaguide.com
http://www.freejavaguide.com/history.html 2/7
Thefirstcharacteristic,objectorientation("OO"),referstoamethodofprogrammingand
languagedesign.AlthoughtherearemanyinterpretationsofOO,oneprimarydistinguishing
ideaistodesignsoftwaresothatthevarioustypesofdataitmanipulatesarecombined
togetherwiththeirrelevantoperations.Thus,dataandcodearecombinedintoentitiescalled
objects.Anobjectcanbethoughtofasaselfcontainedbundleofbehavior(code)andstate
(data).Theprincipleistoseparatethethingsthatchangefromthethingsthatstaythesame
often,achangetosomedatastructurerequiresacorrespondingchangetothecodethat
operatesonthatdata,orviceversa.Thisseparationintocoherentobjectsprovidesamore
stablefoundationforasoftwaresystem'sdesign.Theintentistomakelargesoftware
projectseasiertomanage,thusimprovingqualityandreducingthenumberoffailedprojects.
AnotherprimarygoalofOOprogrammingistodevelopmoregenericobjectssothatsoftware
canbecomemorereusablebetweenprojects.Ageneric"customer"object,forexample,
shouldhaveroughlythesamebasicsetofbehaviorsbetweendifferentsoftwareprojects,
especiallywhentheseprojectsoverlaponsomefundamentallevelastheyoftendoinlarge
organizations.Inthissense,softwareobjectscanhopefullybeseenmoreaspluggable
components,helpingthesoftwareindustrybuildprojectslargelyfromexistingandwelltested
pieces,thusleadingtoamassivereductionindevelopmenttimes.Softwarereusabilityhas
metwithmixedpracticalresults,withtwomaindifficulties:thedesignoftrulygenericobjects
ispoorlyunderstood,andamethodologyforbroadcommunicationofreuseopportunitiesis
lacking.Someopensourcecommunitieswanttohelpeasethereuseproblem,byproviding
authorswithwaystodisseminateinformationaboutgenerallyreusableobjectsandobject
libraries.
Platformindependence
Thesecondcharacteristic,platformindependence,meansthatprogramswrittenintheJava
languagemustrunsimilarlyondiversehardware.Oneshouldbeabletowriteaprogramonce
andrunitanywhere.
ThisisachievedbymostJavacompilersbycompilingtheJavalanguagecode"halfway"to
bytecode(specificallyJavabytecode)simplifiedmachineinstructionsspecifictotheJava
platform.Thecodeisthenrunonavirtualmachine(VM),aprogramwritteninnativecodeon
thehosthardwarethatinterpretsandexecutesgenericJavabytecode.Further,standardized
librariesareprovidedtoallowaccesstofeaturesofthehostmachines(suchasgraphics,
threadingandnetworking)inunifiedways.Notethat,althoughthere'sanexplicitcompiling
stage,atsomepoint,theJavabytecodeisinterpretedorconvertedtonativemachine
instructionsbytheJITcompiler.
TherearealsoimplementationsofJavacompilersthatcompiletonativeobjectcode,suchas
GCJ,removingtheintermediatebytecodestage,buttheoutputofthesecompilerscanonly
berunonasinglearchitecture.
Sun'slicenseforJavainsiststhatallimplementationsbe"compatible".Thisresultedina
legaldisputewithMicrosoftafterSunclaimedthattheMicrosoftimplementationdidnot
supporttheRMIandJNIinterfacesandhadaddedplatformspecificfeaturesoftheirown.In
response,MicrosoftnolongershipsJavawithWindows,andinrecentversionsofWindows,
InternetExplorercannotsupportJavaappletswithoutathirdpartyplugin.However,Sunand
othershavemadeavailableJavaruntimesystemsatnocostforthoseandotherversionsof
Windows.
Thefirstimplementationsofthelanguageusedaninterpretedvirtualmachinetoachieve
portability.Theseimplementationsproducedprogramsthatranmoreslowlythanprograms
10/3/2014 History of Java programming language | www.freejavaguide.com
http://www.freejavaguide.com/history.html 3/7
compiledtonativeexecutables,forinstancewritteninCorC++,sothelanguagesuffereda
reputationforpoorperformance.MorerecentJVMimplementationsproduceprogramsthat
runsignificantlyfasterthanbefore,usingmultipletechniques.
Thefirsttechniqueistosimplycompiledirectlyintonativecodelikeamoretraditional
compiler,skippingbytecodesentirely.Thisachievesgoodperformance,butattheexpense
ofportability.Anothertechnique,knownasjustintimecompilation(JIT),translatestheJava
bytecodesintonativecodeatthetimethattheprogramisrunwhichresultsinaprogramthat
executesfasterthaninterpretedcodebutalsoincurscompilationoverheadduringexecution.
MoresophisticatedVMsusedynamicrecompilation,inwhichtheVMcananalyzethe
behavioroftherunningprogramandselectivelyrecompileandoptimizecriticalpartsofthe
program.Dynamicrecompilationcanachieveoptimizationssuperiortostaticcompilation
becausethedynamiccompilercanbaseoptimizationsonknowledgeabouttheruntime
environmentandthesetofloadedclasses.JITcompilationanddynamicrecompilationallow
Javaprogramstotakeadvantageofthespeedofnativecodewithoutlosingportability.
Portabilityisatechnicallydifficultgoaltoachieve,andJava'ssuccessatthatgoalhasbeen
mixed.AlthoughitisindeedpossibletowriteprogramsfortheJavaplatformthatbehave
consistentlyacrossmanyhostplatforms,thelargenumberofavailableplatformswithsmall
errorsorinconsistenciesledsometoparodySun's"Writeonce,runanywhere"sloganas
"Writeonce,debugeverywhere".
PlatformindependentJavaishoweververysuccessfulwithserversideapplications,suchas
Webservices,servlets,andEnterpriseJavaBeans,aswellaswithEmbeddedsystems
basedonOSGi,usingEmbeddedJavaenvironments.
Automaticgarbagecollection
OneideabehindJava'sautomaticmemorymanagementmodelisthatprogrammersshould
besparedtheburdenofhavingtoperformmanualmemorymanagement.Insomelanguages
theprogrammerallocatesmemorytocreateanyobjectstoredontheheapandis
responsibleforlatermanuallydeallocatingthatmemorytodeleteanysuchobjects.Ifa
programmerforgetstodeallocatememoryorwritescodethatfailstodosoinatimely
fashion,amemoryleakcanoccur:theprogramwillconsumeapotentiallyarbitrarilylarge
amountofmemory.Inaddition,ifaregionofmemoryisdeallocatedtwice,theprogramcan
becomeunstableandmaycrash.Finally,innongarbagecollectedenvironments,thereisa
certaindegreeofoverheadandcomplexityofusercodetotrackandfinalizeallocations.
InJava,thispotentialproblemisavoidedbyautomaticgarbagecollection.Theprogrammer
determineswhenobjectsarecreated,andtheJavaruntimeisresponsibleformanagingthe
object'slifecycle.Theprogramorotherobjectscanreferenceanobjectbyholdinga
referencetoit(which,fromalowlevelpointofview,isitsaddressontheheap).Whenno
referencestoanobjectremain,theJavagarbagecollectorautomaticallydeletesthe
unreachableobject,freeingmemoryandpreventingamemoryleak.Memoryleaksmaystill
occurifaprogrammer'scodeholdsareferencetoanobjectthatisnolongerneededin
otherwords,theycanstilloccurbutathigherconceptuallevels.
Theuseofgarbagecollectioninalanguagecanalsoaffectprogrammingparadigms.If,for
example,thedeveloperassumesthatthecostofmemoryallocation/recollectionislow,they
maychoosetomorefreelyconstructobjectsinsteadofpreinitializing,holdingandreusing
them.Withthesmallcostofpotentialperformancepenalties(innerloopconstructionof
large/complexobjects),thisfacilitatesthreadisolation(noneedtosynchronizeasdifferent
threadsworkondifferentobjectinstances)anddatahiding.Theuseoftransientimmutable
10/3/2014 History of Java programming language | www.freejavaguide.com
http://www.freejavaguide.com/history.html 4/7
valueobjectsminimizessideeffectprogramming.
ComparingJavaandC++,itispossibleinC++toimplementsimilarfunctionality(for
example,amemorymanagementmodelforspecificclassescanbedesignedinC++to
improvespeedandlowermemoryfragmentationconsiderably),withthepossiblecostofextra
developmenttimeandsomeapplicationcomplexity.InJava,garbagecollectionisbuiltinand
virtuallyinvisibletothedeveloper.Thatis,developersmayhavenonotionofwhengarbage
collectionwilltakeplaceasitmaynotnecessarilycorrelatewithanyactionsbeingexplicitly
performedbythecodetheywrite.Dependingonintendedapplication,thiscanbebeneficial
ordisadvantageous:theprogrammerisfreedfromperforminglowleveltasks,butatthesame
timelosestheoptionofwritinglowerlevelcode.
Syntax
ThesyntaxofJavaislargelyderivedfromC++.However,unlikeC++,whichcombinesthe
syntaxforstructured,generic,andobjectorientedprogramming,Javawasbuiltfromthe
grounduptobevirtuallyfullyobjectoriented:everythinginJavaisanobjectwiththe
exceptionsofatomicdatatypes(ordinalandrealnumbers,booleanvalues,andcharacters)
andeverythinginJavaiswritteninsideaclass.
Applet
Javaappletsareprogramsthatareembeddedinotherapplications,typicallyinaWebpage
displayedinaWebbrowser.
//Hello.java
importjava.applet.Applet
importjava.awt.Graphics
publicclassHelloextendsApplet{
publicvoidpaint(Graphicsgc){
gc.drawString("Hello,world!",65,95)
}
}
Thisappletwillsimplydrawthestring"Hello,world!"intherectanglewithinwhichtheapplet
willrun.ThisisaslightlybetterexampleofusingJava'sOOfeaturesinthattheclass
explicitlyextendsthebasic"Applet"class,thatitoverridesthe"paint"methodandthatit
usesimportstatements.
<!Hello.html>
<html>
<head>
<title>HelloWorldApplet</title>
</head>
<body>
<appletcode="Hello"width="200"height="200">
</applet>
</body>
</html>
AnappletisplacedinanHTMLdocumentusingthe<applet>HTMLelement.Theapplettag
hasthreeattributesset:code="Hello"specifiesthenameoftheAppletclassand
10/3/2014 History of Java programming language | www.freejavaguide.com
http://www.freejavaguide.com/history.html 5/7
width="200"height="200"setsthepixelwidthandheightoftheapplet.(Appletsmayalsobe
embeddedinHTMLusingeithertheobjectorembedelement,althoughsupportforthese
elementsbyWebbrowsersisinconsistent.
Servlet
JavaservletsareserversideJavaEEcomponentsthatgenerateresponsestorequestsfrom
clients.
//Hello.java
importjava.io.*
importjavax.servlet.*
publicclassHelloextendsGenericServlet{
publicvoidservice(ServletRequestrequest,ServletResponseresponse)
throwsServletException,IOException
{
response.setContentType("text/html")
PrintWriterpw=response.getWriter()
pw.println("Hello,world!")
pw.close()
}
}
TheimportstatementsdirecttheJavacompilertoincludeallofthepublicclassesand
interfacesfromthejava.ioandjavax.servletpackagesinthecompilation.TheHelloclass
extendstheGenericServletclasstheGenericServletclassprovidestheinterfaceforthe
servertoforwardrequeststotheservletandcontroltheservlet'slifecycle.
TheHelloclassoverridestheservice(ServletRequest,ServletResponse)methoddefinedby
theServletinterfacetoprovidethecodefortheservicerequesthandler.Theservice()method
ispassedaServletRequestobjectthatcontainstherequestfromtheclientanda
ServletResponseobjectusedtocreatetheresponsereturnedtotheclient.Theservice()
methoddeclaresthatitthrowstheexceptionsServletExceptionandIOExceptionifaproblem
preventsitfromrespondingtotherequest.
ThesetContentType(String)methodintheresponseobjectiscalledtosettheMIMEcontent
typeofthereturneddatato"text/html".ThegetWriter()methodintheresponsereturnsa
PrintWriterobjectthatisusedtowritethedatathatissenttotheclient.Theprintln(String)
methodiscalledtowritethe"Hello,world!"stringtotheresponseandthentheclose()
methodiscalledtoclosetheprintwriter,whichcausesthedatathathasbeenwrittentothe
streamtobereturnedtotheclient.
Swingapplication
SwingistheadvancedgraphicaluserinterfacelibraryfortheJavaSEplatform.
//Hello.java
importjavax.swing.*
publicclassHelloextendsJFrame{
Hello(){
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
10/3/2014 History of Java programming language | www.freejavaguide.com
http://www.freejavaguide.com/history.html 6/7
add(newJLabel("Hello,world!"))
pack()
}
publicstaticvoidmain(String[]args){
newHello().setVisible(true)
}
}
TheimportstatementdirectstheJavacompilertoincludeallofthepublicclassesand
interfacesfromthejavax.swingpackageinthecompilation.TheHelloclassextendsthe
JFrameclasstheJFrameclassimplementsawindowwithatitlebarwithaclosecontrol.
TheHello()constructorinitializestheframebyfirstcallingthesetDefaultCloseOperation(int)
methodinheritedfromJFrametosetthedefaultoperationwhentheclosecontrolonthetitle
barisselectedtoWindowConstants.DISPOSE_ON_CLOSEthiscausestheJFrametobe
disposedofwhentheframeisclosed(asopposedtomerelyhidden),whichallowstheJVM
toexitandtheprogramtoterminate.NextanewJLabeliscreatedforthestring"Hello,
world!"andtheadd(Component)methodinheritedfromtheContainersuperclassiscalledto
addthelabeltotheframe.Thepack()methodinheritedfromtheWindowsuperclassiscalled
tosizethewindowandlayoutitscontents.
Themain()methodiscalledbytheJVMwhentheprogramstarts.ItinstantiatesanewHello
frameandcausesittobedisplayedbycallingthesetVisible(boolean)methodinheritedfrom
theComponentsuperclasswiththebooleanparametertrue.Notethatoncetheframeis
displayed,exitingthemainmethoddoesnotcausetheprogramtoterminatebecausethe
AWTeventdispatchingthreadremainsactiveuntilalloftheSwingtoplevelwindowshave
beendisposed.
Lookandfeel
ThedefaultlookandfeelofGUIapplicationswritteninJavausingtheSwingtoolkitisvery
differentfromnativeapplications.Itispossibletospecifyadifferentlookandfeelthroughthe
pluggablelookandfeelsystemofSwing.ClonesofWindows,GTKandMotifaresuppliedby
Sun.ApplealsoprovidesanAqualookandfeelforMacOSX.Thoughpriorimplementations
oftheselookandfeelshavebeenconsideredlacking,SwinginJavaSE6addressesthis
problembyusingmorenativewidgetdrawingroutinesoftheunderlyingplatforms.
Alternatively,thirdpartytoolkitssuchaswx4jorSWTmaybeusedforincreasedintegration
withthenativewindowingsystem.
LackofOOpurityandfacilities
Java'sprimitivetypesarenotobjects.Primitivetypesholdtheirvaluesinthestackrather
thanbeingreferencestovalues.ThiswasaconsciousdecisionbyJava'sdesignersfor
performancereasons.Becauseofthis,Javaisnotconsideredtobeapureobjectoriented
programminglanguage.However,asofJava5.0,autoboxingenablesprogrammerstowrite
asifprimitivetypesaretheirwrapperclasses,andfreelyinterchangebetweenthemfor
improvedflexibility.Javadesignersdecidednottoimplementcertainfeaturespresentinother
OOlanguages,including:
*multipleinheritance
*operatoroverloading
*classproperties
10/3/2014 History of Java programming language | www.freejavaguide.com
http://www.freejavaguide.com/history.html 7/7
*tuples
JavaRuntimeEnvironment
TheJavaRuntimeEnvironmentorJREisthesoftwarerequiredtorunanyapplication
deployedontheJavaPlatform.EnduserscommonlyuseaJREinsoftwarepackagesand
Webbrowserplugins.SunalsodistributesasupersetoftheJREcalledtheJava2SDK
(morecommonlyknownastheJDK),whichincludesdevelopmenttoolssuchastheJava
compiler,Javadoc,anddebugger.
Abovearti cl eori gi nal l yfromwi ki pedi a.org.Abovearti cl ei savai l abl eunderGNUFreeDocumentati onLi cense.
Copyright20062013FreeJavaGuide&Tutorials.AllRightsReserved.

Vous aimerez peut-être aussi