SCJP Ch10 Development and Deployment

SCJP Ch10 Development and Deployment

ID:38056287

大小:1.01 MB

页数:4页

时间:2019-05-24

SCJP Ch10 Development and Deployment_第1页
SCJP Ch10 Development and Deployment_第2页
SCJP Ch10 Development and Deployment_第3页
SCJP Ch10 Development and Deployment_第4页
资源描述:

《SCJP Ch10 Development and Deployment》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、SCJPStudyNotes:Chapter10DevelopmentChapter10Development1.UsingthejavacandjavaCommands1.1CompilingwithjavacIntheexam,youneedtounderstand–classpathand–doptionjavac[options][sourcefiles]javac-help-classpathoptionjavac-classpathcom:.-gFoo.javaBar.java-doption(assu

2、menopackagestatement)MyClass.classcurrentdirectoryjavac-dclassessource/MyClass.javaðtellthecompilertoputthe.classfiletoclassesdirð=>d(destination)-doptionwithpackagestatementcurrentdirectorypackagecom.wickedlysmart;publicclassMyClass{}javac-d../classescom/wick

3、edlysmart/MyClass.javaðIfcom/wickedlysmartnotexist,the-doptionwillbuildit.ðButifclassesdirnotexist=>ERROR4SCJPStudyNotes:Chapter10Development1.2LaunchingApplicationswithjavajava[options]class[args]java-DmyProp=myValueMyClassx1ðCreateasystempropertycalledmyProp

4、andsetitsvaluetomyValueðthevaluepairisretrievedinSystem.getProperties()java-DcmdProp="cmdValtake2"TestProps//ifthevaluecontainspaceCommandLineArgumentsLegalDeclaration:staticpublicvoidmain(String[]args)publicstaticvoidmain(String...x)staticpublicvoidmain(Strin

5、gbang_a_gong[])args[0],args[1],…ifaccessargs[1]withouttheactualarg=>ArrayIndexOutofBound1.3SearchingforOtherClassesBothjavaandjavacusethesamesearchalgorithm1.thefirstplacetheylookatthedirectorycomestandardwithJ2SE2.thesecondplaceisthedirectorydefinedbyclasspat

6、h3.classpathcanbedefinedinOSenvvarorincommandlineinjavaandjavac4.commandlineoverridetheenvvare.g.–classpath/com/foo/acct:/com/fooothesearchpathisseparatedby“:”,“/”meansrootdirectoryonotedthatsubdirectory,e.g./comwillNOTbesearchedoinwindows,use“;”and“”ocanuse-

7、cpe.g.-classpath/com/foo/acct:/com/foo:.“.”=>searchalsothecurrentdirectoryPackagesandSearchingpackagecom.foo;publicclassMyClass{publicvoidhi(){}}importcom.foo.MyClass;importcom.foo.*;publicclassAnother{voidgo(){MyClassm1=newMyClass();//aliasnamecom.foo.Myclass

8、m2=newcom.foo.MyClass();//fullname}}4SCJPStudyNotes:Chapter10DevelopmentRelativeandAbsolutePathse.g.-cpdirB:dirB/dirCodirBanddirB/dirCarerelativepaths(theydon'tstartwithaslash/).ow

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。