



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
SCJP Study Notes: Chapter 10 DevelopmentChapter 10 Development1. Using the javac and java Commands1.1 Compiling with javacIn the exam, you need to understand classpath and d option javac options source files javac -help -classpath optionjavac -classpath com:. -g Foo.java Bar.java-d option (assume no package statement)MyClass.classcurrent directoryjavac -d classes source/MyClass.java tell the compiler to put the .class file to classes dir = d (destination)-d option with package statementcurrent directorypackage com.wickedlysmart;public class MyClass javac -d ./classes com/wickedlysmart/MyClass.java If com/wickedlysmart not exist, the -d option will build it. But if classes dir not exist = ERROR1.2 Launching Applications with java java options class argsjava -DmyProp=myValue MyClass x 1 Create a system property called myProp and set its value to myValue the value pair is retrieved in System.getProperties( )java -DcmdProp=cmdVal take 2 TestProps/ if the value contain spaceCommand Line ArgumentsLegal Declaration:static public void main(String args) public static void main(String. x) static public void main(String bang_a_gong)args0, args1, if access args1 without the actual arg = ArrayIndexOutofBound1.3 Searching for Other ClassesBoth java and javac use the same search algorithm1. the first place they look at the directory come standard with J2SE2. the second place is the directory defined by classpath3. classpath can be defined in OS env var or in command line in java and javac4. command line override the env vare.g. classpath /com/foo/acct:/com/fooo the search path is separated by “:”, “/” means root directoryo noted that subdirectory, e.g. /com will NOT be searchedo in windows, use “;” and “”o can use -cpe.g. -classpath /com/foo/acct:/com/foo:.“.” = search also the current directoryPackages and Searchingpackage com.foo;public class MyClass public void hi( ) import com.foo.MyClass;import com.foo.*;public class Anothervoid go( ) MyClass m1 = new MyClass( );/ alias namecom.foo.Myclass m2 = new com.foo.MyClass( );/ full nameRelative and Absolute Pathse.g. -cp dirB:dirB/dirCo dirB and dirB/dirC are relative paths (they dont start with a slash /).o when the current directory is dirA, dirB and dirC will be searched, but not dirAo when the current directory is root, since dirB is not a direct subdirectory of root, no directories will be searchedo when the current directory is dirB, no directory will be searchede.g. -cp /dirB:/dirA/dirB/dirCo current directory is dirA, root? dirB? both paths in the classpath are absolute, it doesnt matter what is the current directory, /dirB is invalid since it is not a direct subdir of root, the ans is ONLY dirC2. JAR Files* You dont need to know how to make JAR files for the examo jar command create META-INF directory and MANIFEST.MF file automaticallyo jar command wont place any of your files in META-INF/Finding a JAR file using a classpath is similar to finding a package file in a classpath. The difference is that when you specify a path for a JAR file, you must include the name of the JAR file at the end of the pathjavac -classpath ws/myApp.jar UseStuff.javajavac -classpath ws UseStuff.java put JAR files into the ext subdirectory, java and javac can find them3. Using Static Importso What import statements do are just they save typing and make code easier to reado static import can import classs static member, static object and static membero if import both Integer and Long class and refer to MAX_VALUE = ERRORBefore static import:System.out.println(Integer.MAX_VALU
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年4月重庆医科大学附属第三医院招聘医师、医技、护理、行政、其他岗位模拟试卷有答案详解
- 2025嘉兴市保安服务有限公司招聘2人考前自测高频考点模拟试题附答案详解(考试直接用)
- 2025年攀枝花市盐边县事业单位春季引才考核的模拟试卷及1套参考答案详解
- 2025河南郑州智能科技职业学院招聘考前自测高频考点模拟试题附答案详解(模拟题)
- 2025湖北武汉大学中南医院咸宁医院咸宁市第一人民医院招聘15人模拟试卷有答案详解
- 2025年福建省龙岩市武平县招聘教育卫生干部10人模拟试卷有答案详解
- 2025安徽蚌埠市《固镇县任桥镇2025年面向全县公开招聘村级后备干部》考前自测高频考点模拟试题及1套参考答案详解
- 山西省【中职专业高考】2025年中职高考对口升学(理论考试)真题卷【农林牧渔大类】模拟练习
- 2025广东珠海市香洲区招聘卫生健康系统事业单位人员10人及完整答案详解一套
- IBI-325-生命科学试剂-MCE
- 收单外包管理办法
- 分时租赁介绍课件
- 第七章-大学生创业实践案例课件
- 燃机三菱控制系统简述课件
- 全尺寸测量报告FAI
- (完整)农村污水处理工程施工组织设计
- 认识五线谱精选PPT
- 维力能醋酸钠林格注射液
- 五四制青岛版2022-2023五年级科学上册第四单元第12课《安全用药》课件(定稿)
- 直播场景搭建
- 专题复习七选五的解题技巧课件(共22张)-副本-副本
评论
0/150
提交评论