欢迎来到天天文库
浏览记录
ID:38056287
大小:1.01 MB
页数:4页
时间:2019-05-24
《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
此文档下载收益归作者所有