CORE JAVA 9Chapter 2Word格式文档下载.docx

上传人:b****7 文档编号:22384567 上传时间:2023-02-03 格式:DOCX 页数:21 大小:895.91KB
下载 相关 举报
CORE JAVA 9Chapter 2Word格式文档下载.docx_第1页
第1页 / 共21页
CORE JAVA 9Chapter 2Word格式文档下载.docx_第2页
第2页 / 共21页
CORE JAVA 9Chapter 2Word格式文档下载.docx_第3页
第3页 / 共21页
CORE JAVA 9Chapter 2Word格式文档下载.docx_第4页
第4页 / 共21页
CORE JAVA 9Chapter 2Word格式文档下载.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

CORE JAVA 9Chapter 2Word格式文档下载.docx

《CORE JAVA 9Chapter 2Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《CORE JAVA 9Chapter 2Word格式文档下载.docx(21页珍藏版)》请在冰豆网上搜索。

CORE JAVA 9Chapter 2Word格式文档下载.docx

2.1.1.DownloadingtheJDK

TodownloadtheJavaDevelopmentKit,visitthewebsiteat 

bepreparedtodecipheranamazingamountofjargonbeforeyoucangetthesoftwareyouneed.See 

Table2.1 

forasummary.

Table2.1.JavaJargon

YoualreadysawtheabbreviationJDKforJavaDevelopmentKit.Somewhatconfusingly,versions1.2through1.4ofthekitwereknownastheJavaSDK(SoftwareDevelopmentKit).Youwillstillfindoccasionalreferencestotheoldterm.ThereisalsoaJavaRuntimeEnvironment(JRE)thatcontainsthevirtualmachinebutnotthecompiler.Thatisnotwhatyouwantasadeveloper.Itisintendedforenduserswhohavenoneedforthecompiler.

Next,you’llseethetermJavaSEeverywhere.ThatistheJavaStandardEdition,incontrasttoJavaEE(EnterpriseEdition)andJavaME(MicroEdition).

YouwilloccasionallyrunintothetermJava2thatwascoinedin1998whenthemarketingfolksatSunfeltthatafractionalversionnumberincrementdidnotproperlycommunicatethemomentousadvancesofJDK1.2.However,becausetheyhadthatinsightonlyaftertherelease,theydecidedtokeeptheversionnumber1.2forthedevelopmentkit.Subsequentreleaseswerenumbered1.3,1.4,and5.0.The 

platform,however,wasrenamedfromJavatoJava2.Thus,wehadJava2StandardEditionSoftwareDevelopmentKitVersion5.0,orJ2SESDK5.0.

Forengineers,allofthiswasabitconfusing,butthat’swhywenevermadeitintomarketing.Mercifully,in2006,sanityprevailed.TheuselessJava2monikerwasdropped,andthecurrentversionoftheJavaStandardEditionwascalledJavaSE6.Youwillstillseeoccasionalreferencestoversions1.5and1.6—thesearejustsynonymsforversions5.0and6.

Finally,whenOraclemakesaminorversionchangetofixurgentissues,itreferstothechangeasanupdate.Forexample,thefirstupdateofthedevelopmentkitforJavaSE7isofficiallycalledJDK7u1andhastheinternalversionnumber1.7.0_01.Anupdatedoesnotneedtobeinstalledoverapriorversion—itcontainsthemostcurrentversionofthewholeJDK.

Sometimes,OraclemakesavailablebundlesthatcontainboththeJavaDevelopmentKitandanintegrateddevelopmentenvironment.Thatintegratedenvironmenthas,atdifferenttimesofitslife,beennamedForte,SunONEStudio,SunJavaStudio,andNetbeans.Wedonotknowwhattheeagerbeaversinmarketingwillcallitwhenyouapproachthedownloadsite.WesuggestthatyoustayawayfromallbundlesandinstallonlytheJavaDevelopmentKitatthistime.IfyoulaterdecidetouseOracle’sintegrateddevelopmentenvironment,simplydownloaditfrom 

http:

//netbeans.org.

 

Note

ThesetupprocedureoffersadefaultfortheinstallationdirectorythatcontainstheJDKversionnumber,suchas 

jdk1.7.0.Thissoundslikeabother,butwehavecometoappreciatetheversionnumber—itmakesiteasiertoinstallanewerJDKreleasefortesting.

UnderWindows,westronglyrecommendthatyoudonotacceptadefaultlocationwithspacesinthepathname,suchas 

c:

\ProgramFiles\jdk1.7.0.Justtakeoutthe 

ProgramFiles 

partofthepathname.

Inthisbook,werefertotheinstallationdirectoryas 

jdk.Forexample,whenwerefertothe 

jdk/bindirectory,wemeanthedirectorywithanamesuchas 

/usr/local/jdk1.7.0/bin 

or 

\jdk1.7.0\bin.

2.1.2.SettingtheExecutablePath

AfteryouaredoneinstallingtheJDK,youneedtocarryoutoneadditionalstep:

Addthe 

jdk/bin 

directorytotheexecutablepath—thelistofdirectoriesthattheoperatingsystemtraversestolocateexecutablefiles.Directionsforthisstepalsovaryamongoperatingsystems.

•InUNIX(includingLinux,MacOSX,andSolaris),theprocedureforeditingtheexecutablepathdependsontheshellyouareusing.IfyouusetheBourneAgainshell(whichistheLinuxdefault),thenaddalinesuchasthefollowingtotheendofyour 

~/.bashrc 

~/.bash_profile 

file:

exportPATH=jdk/bin:

$PATH

•UnderWindows,loginasadministrator.StarttheControlPanel,switchtoClassicView,andselecttheSystemicon.InWindowsXP,youimmediatelygetthesystempropertiesdialog.InVistaandWindows7,youneedtoselectAdvancedSystemSettings(see 

Figure2.1).Inthesystempropertiesdialog,clicktheAdvancedtab,thenclickontheEnvironmentbutton.ScrollthroughtheSystemVariableswindowuntilyoufindavariablenamed 

Path.ClicktheEditbutton(see 

Figure2.2).Addthe 

jdk\bin 

directorytothebeginningofthepath,usingasemicolontoseparatethenewentry,likethis:

jdk\bin;

otherstuff

Figure2.1.LaunchingthesystempropertiesdialoginWindowsVista

Figure2.2.Settingthe 

Path 

environmentvariableinWindowsVista

Becarefultoreplace 

jdk 

withtheactualpathtoyourJavainstallation,suchas 

\jdk1.7.0_02.IfyouignoredouradvicetodroptheProgramFiles 

directory,enclosetheentirepathindoublequotes:

"

\ProgramFiles\jdk1.7.0_02\bin"

;

otherstuff.

Saveyoursettings.Anynewconsolewindowsthatyoustartwillhavethecorrectpath.

Hereishowyoutestwhetheryoudiditright:

Startashellwindow.Typetheline

javac-version

andpresstheEnterkey.Youshouldgetadisplaysuchasthisone:

javac1.7.0_02

Ifinsteadyougetamessagesuchas“javac:

commandnotfound”or“Thenamespecifiedisnotrecognizedasaninternalorexternalcommand,operableprogramorbatchfile”,thenyouneedtogobackanddouble-checkyourinstallation.

InWindows,followtheseinstructionstoopenashellwindow.IfyouuseWindowsXP,selecttheRunoptionfromtheStartmenuandtype 

cmd.InVistaandWindows7,simplytype 

cmd 

intotheStartSearchfieldintheStartmenu.PressEnter,andashellwindowappears.

Ifyou’veneverseenoneofthese,wesuggestthatyouworkthroughatutorialthatteachesthebasicsaboutthecommandline,suchas 

2.1.3.InstallingtheLibrarySourceandDocumentation

ThelibrarysourcefilesaredeliveredintheJDKasacompressedfile 

src.zip,andyoumustunpackthatfiletogetaccesstothesourcecode.Wehighlyrecommendthatyoudothat.Simplydothefollowing:

1. 

MakesuretheJDKisinstalledandthatthe 

directoryisontheexecutablepath.

2. 

Openashellwindow.

3. 

Changetothe 

directory(e.g., 

cd/usr/local/jdk1.7.0 

cdc:

\jdk1.7.0).

4. 

Makeasubdirectory 

src:

mkdirsrc

cdsrc

5. 

Executethecommand

jarxvf../src.zip

(or 

jarxvf..\src.zip 

onWindows).

Tip

The 

src.zip 

filecontainsthesourcecodeforallpubliclibraries.Toobtainevenmoresource(forthecompiler,thevirtualmachine,thenativemethods,andtheprivatehelperclasses),goto 

.

ThedocumentationiscontainedinacompressedfilethatisseparatefromtheJDK.YoucandownloadthedocumentationSimplyfollowthesesteps:

Downloadthedocumentationzipfileandmoveitintothe 

directory.Thefileiscalled 

jdk-version-apidocs.zip,where 

version 

issomethinglike 

7.

directory.

jarxvfjdk-version-apidocs.zip

where 

istheappropriateversionnumber.

2.1.4.InstallingtheCoreJavaProgramExamples

Youshouldalsoinstallthe 

CoreJava 

programexamples.Youcandownloadthemfrom 

Theprogramsarepackagedintoazipfile 

corejava.zip.Youshouldunzipthemintoaseparatedirectory—werecommendyoucallit 

CoreJavaBook.Herearethesteps:

MakesuretheJDKisinstalledandthe 

directoryisontheexecutionpath.

Makeadirectory 

CoreJavaBook.

Downloadthe 

corejava.zip 

filetothatdirectory.

CoreJavaBook 

6. 

jarxvfcorejava.zip

2.1.5.NavigatingtheJavaDirectories

InyourexplorationsofJava,youwilloccasionallywanttopeekinsidetheJavasourcefiles.And,ofcourse,youwillneedtoworkextensivelywiththelibrarydocumentation. 

Figure2.3 

showstheJDKdirectorytree.

Figure2.3.Javadirectorytree

ThetwomostusefulsubdirectoriesforlearningJavaare 

docs 

and 

src.The 

directorycontainstheJavalibrarydocumentationinHTMLformat.Youcanviewitwithanywebbrowser,suchasFirefox.

Ti

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

当前位置:首页 > 人文社科 > 视频讲堂

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1