



如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
SCJPStudyNotes:Chapter10Development Chapter10Development 1.UsingthejavacandjavaCommands 1.1Compilingwithjavac Intheexam,youneedtounderstand–classpathand–doption javac[options][sourcefiles] javac-help -classpathoption javac-classpathcom:.-gFoo.javaBar.java -doption(assumenopackagestatement) MyClass.class currentdirectory javac-dclassessource/MyClass.java tellthecompilertoputthe.classfiletoclassesdir =>d(destination) -doptionwithpackagestatement currentdirectory packagecom.wickedlysmart; publicclassMyClass{} javac-d../classescom/wickedlysmart/MyClass.java Ifcom/wickedlysmartnotexist,the-doptionwillbuildit. Butifclassesdirnotexist=>ERROR 1.2LaunchingApplicationswithjava java[options]class[args] java-DmyProp=myValueMyClassx1 CreateasystempropertycalledmyPropandsetitsvaluetomyValue thevaluepairisretrievedinSystem.getProperties() java-DcmdProp="cmdValtake2"TestProps //ifthevaluecontainspace CommandLineArguments LegalDeclaration: staticpublicvoidmain(String[]args) publicstaticvoidmain(String...x) staticpublicvoidmain(Stringbang_a_gong[]) args[0],args[1],…ifaccessargs[1]withouttheactualarg=>ArrayIndexOutofBound 1.3SearchingforOtherClasses Bothjavaandjavacusethesamesearchalgorithm thefirstplacetheylookatthedirectorycomestandardwithJ2SE thesecondplaceisthedirectorydefinedbyclasspath classpathcanbedefinedinOSenvvarorincommandlineinjavaandjavac commandlineoverridetheenvvar e.g.–classpath/com/foo/acct:/com/foo thesearchpathisseparatedby“:”,“/”meansrootdirectory notedthatsubdirectory,e.g./comwillNOTbesearched inwindows,use“;”and“\” canuse-cp e.g.-classpath/com/foo/acct:/com/foo:. “.”=>searchalsothecurrentdirectory PackagesandSearching packagecom.foo; publicclassMyClass{publicvoidhi(){}} importcom.foo.MyClass; importcom.foo.*; publicclassAnother{ voidgo(){ MyClassm1=newMyClass(); //aliasname com.foo.Myclassm2=newcom.foo.MyClass(); //fullname } } RelativeandAbsolutePaths e.g.-cpdirB:dirB/dirC dirBanddirB/dirCarerelativepaths(theydon'tstartwit

ys****39
实名认证
内容提供者


最近下载