【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx

上传人:聆听****声音 文档编号:852941 上传时间:2023-04-29 格式:DOCX 页数:22 大小:998.28KB
下载 相关 举报
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第1页
第1页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第2页
第2页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第3页
第3页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第4页
第4页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第5页
第5页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第6页
第6页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第7页
第7页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第8页
第8页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第9页
第9页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第10页
第10页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第11页
第11页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第12页
第12页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第13页
第13页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第14页
第14页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第15页
第15页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第16页
第16页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第17页
第17页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第18页
第18页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第19页
第19页 / 共22页
【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx_第20页
第20页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx

《【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx(22页珍藏版)》请在冰点文库上搜索。

【精品文档】433关于计算机专业网页小程序有关的外文文献翻译成品:JavaWebStart和小应用程序Applets中英文双语对照11Word文档下载推荐.docx

JavaWebStartandApplets

外文作者:

DavidParsons

文献出处:

FoundationalJava,2019,pp503-527(如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)

英文3584单词,19270字符(字符就是印刷符),中文5622汉字。

(如果字数多了,可自行删减,大多数学校都是要求选取外文的一部分内容进行翻译的。

Initsearlydays,JavacametoprominencebecauseofJavaapplets,runninginwebbrowsers.Appletshavehadsomethingofacheckeredhistorysincethen,andmostJavawebtechnologiesbelongintheenterpriseeditionratherthanthestandardeditionofJava.However,appletsarestillwidelyused,andcanbeausefulcomponentofrichInternetapplications.Alsoassociatedwiththeweb,butlessdirectly,isJavaWebStart,whichallowsdesktopapplicationstobedeployedovertheweb.Inthischapter,wewillbeginbylookingatJavaWebStartandthenlookatapplets,whichcannowusethesamedeploymentmechanismasJavaWebStart,makingitveryeasytoswitchbetweenthetwomodesofdeployment.SincebothJavaWebStartandappletsrequireustocreatewebpageswithappropriatelinkstoJavaapplicationsorapplets,wewillbeginwithbriefoverviewsofwebbrowsers,URLs,andHTML.

20.1WebBrowsers,URLs,andHTMLPages

Webbrowsersoftware(e.g.,Explorer,Firefox,Safari,Chrome,etc.)isdesignedtoretrieveinformationfromremotesitesontheWorldWideWeb(WWW)usingUniformResourceLocators(URLs).MuchoftheinformationismadeavailableintheformofHTML(HyperTextMarkupLanguage)webpages.

20.1.1URLs

AURLisbasicallytheInternetaddressofaresourceonaparticularserver,andtypicallyiswritteninthreeparts:

theprotocol,theserveraddress,andthenameoftheresource(includinganypathinformation).

20.1.1.1TheHTTPProtocol

Theprotocolprefixforwebpagesis“http:

//”.Thisstandsfor“hypertexttransferprotocol”andmostURLsstartthisway.Indeedthispartisoftenomitted,becauseitisusuallythebrowser’sdefaultprotocol(thoughthereareotherwebprotocolsthatyoumaybefamiliarwithsuchasFTP,theFileTransferProtocol).

20.1.1.2TheServerAddress

Theserveraddressusuallybeginswith“www”(WorldWideWeb),followedbythenameofthesiteandits“domain,”whichdefinesitscategoryandmayincludeitscountrycode.Eachoftheseisseparatedbyaperiod(fullstop).Take,forexample,thefollowingURL:

“introjava”isthenameoftheserversiteand“com”meansacompany.Commonalternativesto“com”are“edu”foracademicinstitutionsand“org”fororganizations.ManyURLsarewithinacountrydomain,suchas“.co.uk”or“.ac.nz”.Ifyouarerunningatestserveronyourlocalmachine,thedomainnamebecomes“localhost.”

20.1.1.3ThePathandResourceName

ThefinalpartofaURLcanincludethelocation(directory)andnameoftheparticularfileatthesite.Forexample,

Thislooksforthefile“getinvolved.html”inthe“foundation”directory.Thefilenamewillgenerallyendin“html”(orsometimesjust“htm”)becauseitwillusuallybeafilewritteninHTML(seebelow).Ifnofilenameisspecified,“index.html”isoftentheserver’sdefaultfilenamethatitwillsendbacktothebrowser.Ifnoindexfileispresent,thenadirectorylistingmaybedisplayedinstead,oranerrorpage,dependingontheserver’sconfiguration.

20.1.2HTML(HyperTextMarkupLanguage)

WebbrowsersdisplayscreensofinformationwrittenusingHTML(HyperTextMarkupLanguage).ThebrowsertakesthebasicinformationstoredintheHTMLfileandformatsitappropriatelyusingtagsembeddedintothetextofthefile.AllHTMLfilesbeginwithan<

html>

tagandendwith<

/html>

.MostHTMLtagsareterminatedlikethis,usingaforwardslashfollowedbythetagname.ThisisaverysimpleHTMLfile,showingadditionaltagsforthepageheader(<

head>

whichcanincludeatitle<

title>

),themainbodyofthetext(<

body>

),andsometext.Headertags(suchas<

h1>

)canbeusedtoformatthesizeoftext.The<

p>

tagisusedtospecifyparagraphs.The“DOCTYPE”atthetopthefilespecifiestheversionofHTMLthatisbeingused.ThisexampleusesHTML5(differentDOCTYPEShavedifferentexpectationsabouthowthedocumentshouldbestructured).

Figure20.1showswhatthispagelookslikewhenloadedintoabrowserasalocalfile.Simplefilescaneasilybewrittenbyhand,butformorecomplexpagesitisbettertouseoneofthemanyavailableHTMLeditingtools.SomesimpleHTMLpageswillbeneededtolaunchtheapplicationsandappletsdescribedinthischapter.

20.2JavaWebStart

JavaWebStartisagenericRichInternetApplication(RIA)launchmechanismthatcanbeusedtodeploybothdesktopapplicationsandapplets.Itprovidesawaytoeasilydeployapplicationsviatheweb,andprovidesanalternativetosomeothertypesofwebdeployment,suchassomeserversidewebapplications,thoughitprimarilyeasesthedeploymentofdesktopapplications.AJavaWebStartapplicationcanbeself-contained,becauseitcanautomaticallydownloadandinstallaJRE.ProgrammerscanspecifywhichJREversionagivenprogramneedsinordertoexecuteandensurethatitisavailablefortheapplicationtorun.Althoughitisaweb-baseddeploymentmechanism,noInternetconnectionisrequiredtoexecutetheapplicationsoncetheyhavebeendownloaded.

ThecorecomponentsofaJavaWebStartdeploymentare:

theapplicationtobedeployed,aJavaNetworkLaunchProtocol(JNLP)file,andaweb(HTML)pagetohosttheapplicationlauncher.TheJavaapplicationneedstobearchivedinaJARfilewithanidentifiable“main”classthatservesastheprogramentrypoint.AswesawinChap.14,aJARprovidesasingleunitofdeployment,andcanspecifyamainclassinitsmanifest.Havingthe“main”classidentifiedinthemanifestisnotessentialforJavaWebStartsincewecanalsospecifythemainclassintheJNLPfile,butitisusefulnottorelyentirelyontheJNLPfiletospecifyamainclass.

TheJNLPfileisanXMLfilethatdescribeshowtheapplicationshouldbelaunched.Itcontainsdeployment-relatedinformationsuchasthenameoftheJARfile,themainclassintheJAR,andtheminimumversionofJavarequiredtoruntheapplication.ThewebpagecaneithercontainasimplehyperlinktotheJNLPfileoritcanuseaJavaScriptbuttontolaunchtheapplication.Normally,wewouldalsoneedtosetupawebapplicationsothatthefilescanbedownloadedoverthewebfromaserver.However,fortestingpurposesitispossibletodeployaJavaWebStartapplicationusingalocalHTMLfile,whichwewilldoforthefirstexample,whichdeploystheDistanceViewerapplicationfromChap.18.

20.2.1CreatingaJARinEclipse

ThefirststepistocreateaJARfilecontainingtherequiredclasses.ThiscouldofcoursebebuiltusinganAntscript,whichwewilldolaterinthischapter,butwewilldescribethefirststepinthisexampleusingtheEclipseexportfacility.Figure20.2showsthekeystepsinthedialogsthatexportfilesfromEclipse.Thefirststepistoselect“export”fromthe“file”menu,whichwillopenthe“Export”dialogshowninFig.20.1.Inthisdialog,withinthe“Java”folderyoucanselect“JARFile”asthetypeofexport.Clickingthe“Next”buttontakesyoutothe“JARExport”dialog.Itisessentialheretochooseallofthefilesthatneedtobeinthearchive.Forthe“DistanceViewer”application,youneedtoexportnotonlytheDistanceViewerclassitself(theview),buttheFlightDistancesclassaswell(themodel).ThelowerpartofthedialogletsyouselecttheexportfolderandthenameoftheJARfile.Clicking“Next”takesyoutothefinalstageofthedialogwhereyoucanselectoneoftheclassesintheJARastheclassusedastheapplicationentrypoint.Clicking“Finish”createstheJARfile.

20.2.2JavaNetworkLaunchProtocol(JNLP)

TheJavaNetworkLaunchProtocol(JNLP)enablesadesktopapplicationtobelaunchedfromresourceshostedonawebserver.JavaWebStartrequiresaJNLPfilethatconfiguresthevariousaspectsoftheprotocol.

ThiscanbecreatedasatextfileinEclipse,witha“jnlp”extension.ItneedstobeexplicitlyopenedinatexteditororEclipsemayattempttorunitdirectly(right-clickonthefileandchoose“openwith”,thenselect“texteditor”).ThefollowingexamplecontainsthebasicinformationrequiredinaJNLPfile.The“information”elementrequires“title”and“vendor”information.The“resources”elementspecifiestheminimumversionofJavarequiredtoruntheapplication(withtheURLoftheautomaticdownloadsitefortheJavaruntime),andthenameoftheJARfile.Finallythe“applicationdesc”elementspecifiesthenameofthemainclasstoberunfromtheJAR.ThisparticularJNLPfilehasbeenwrittenusingtherequiredelementsfromJavaWebStartversion1;

hence,the“spec”attributeissetto“1.0+”(thisisactuallythedefault).

Notethatthe“codebase”and“href”attributesareemptyinthisexample–theyarenotrequiredwhentestinglocalfiles.

Hyperlinksdonotparticularlystandoutonawebpage.AnotherwayoflaunchingaJavaWebStartapplicationistouseaJavaScriptbuttontolaunchtheapplication.ThisfragmentofJavaScriptusesthe“deployJava.createWebStartLaunchButton”methodthatisavailableoverthewebfromthe“deployJava.js”file.Thecodethatprocessesitusesthe“href”propertyoftheJavaScript“location”objecttolocatetheJNLPfilerelativetotheURLofthewebpage.

20.2.3DeployingtoaServer

SofarwehaveonlytestedourWebStartapplicationsusinglocalfiles,butofcourseWebStartapplicationsneedtobedeployedtoaserverinordertobedownloadedovertheInternet.Inthissection,wewillcoverthebasicsofdeployingaWebStartapplicationtotheTomcat

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > IT计算机 > 电脑基础知识

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2