Eclipse – 整合开发工具(基础篇)
Jacky Lee
2005/03/01
Eclipse.doc 第 1 页,共 1 页
目录
0.环境说明................................................................................................................................................................ 7
1.Eclipse简介 ............................................................................................................................................................ 8
1.1 历史背景 ..................................................................................................................................................... 8
1.2 开放原始码软件 ......................................................................................................................................... 8
1.3 Eclipse版本介绍 ......................................................................................................................................... 8
1.4 跨语言、跨平台 ......................................................................................................................................... 9
2. Eclipse Platform .................................................................................................................................................. 10
2.1 概观........................................................................................................................................................... 10
2.2 架构........................................................................................................................................................... 10
2.3 项目与资料夹 ........................................................................................................................................... 10
2.4 平台核心 ................................................................................................................................................... 11
2.5 工作区(workspace).................................................................................................................................... 11
2.6 工作台(workbench)................................................................................................................................... 11
2.6.1 视图(View) ..................................................................................................................................... 12
2.6.2 编辑器(Editor)................................................................................................................................ 14
2.6.3 视景(Perspective) ........................................................................................................................... 16
2.7 重新排列视图和编辑器 ........................................................................................................................... 17
2.7.1 放置游标 ........................................................................................................................................ 17
2.7.2 重新排列视图 ................................................................................................................................ 18
2.7.3 并列编辑器 .................................................................................................................................... 18
2.7.4 重新排列附加标签的视图 ............................................................................................................ 19
2.7.5 最大化 ............................................................................................................................................ 19
2.8 菜单和工具列 ........................................................................................................................................... 20
2.8.1 菜单 ................................................................................................................................................ 20
2.8.2 图标和按钮 .................................................................................................................................... 31
2.9 视景........................................................................................................................................................... 35
2.9.1 新视景 ............................................................................................................................................ 35
2.9.2 新窗口 ............................................................................................................................................ 37
2.9.3 储存视景 ........................................................................................................................................ 37
2.9.4 配置视景 ........................................................................................................................................ 39
2.10 作业和标记 ............................................................................................................................................. 40
2.10.1 不相关的作业 .............................................................................................................................. 40
2.10.2 相关的作业 .................................................................................................................................. 41
2.10.3 开启档案 ...................................................................................................................................... 42
2.11 书签 ......................................................................................................................................................... 42
2.11.1 新增和检视书签 .......................................................................................................................... 42
Eclipse 中文教程.doc 第 2 页,共 221 页
2.11.2 使用书签 ...................................................................................................................................... 44
2.11.3 移除书签 ...................................................................................................................................... 44
2.12 快速视图(Fast View)............................................................................................................................... 46
2.12.1 建立快速视图 .............................................................................................................................. 46
2.12.2 使用快速视图 .............................................................................................................................. 46
2.13 比较......................................................................................................................................................... 47
2.13.1 简单比较 ...................................................................................................................................... 48
2.13.2 了解比较 ...................................................................................................................................... 49
2.13.3 使用比较 ...................................................................................................................................... 49
2.14 历史纪录 ................................................................................................................................................. 51
2.15 回应 UI................................................................................................................................................... 52
3.喜好设定(Preferences)......................................................................................................................................... 55
3.1 工作台(Workbench) .................................................................................................................................. 55
3.1.1 外观(Appearance)........................................................................................................................... 57
3.1.2 功能(Capabilities)........................................................................................................................... 58
3.1.3 颜色和字型(Colors and Fonts) ...................................................................................................... 59
3.1.4 比较/修正(Compare/Patch)............................................................................................................ 61
3.1.5 编辑器(Editors) .............................................................................................................................. 63
3.1.6 档案关联(File Associations) .......................................................................................................... 64
3.1.7 按键(Keys) ..................................................................................................................................... 66
3.1.8 标签装饰(Label Decorations) ........................................................................................................ 72
3.1.9 链接资源(Linked Resources)......................................................................................................... 72
3.1.10 历史纪录(Local History).............................................................................................................. 73
3.1.11 视景 .............................................................................................................................................. 74
3.1.12 搜寻(Search)................................................................................................................................. 76
3.1.13 启动和关闭(Startup and Shutdown) ............................................................................................ 76
3.2 Ant ............................................................................................................................................................. 77
3.2.1 Ant 编辑器(Ant Editor) ................................................................................................................. 78
3.2.2 Ant 执行时期(Ant Runtime) ......................................................................................................... 79
3.3 建置次序(Build Order) ............................................................................................................................. 81
3.4 说明(Help)................................................................................................................................................. 82
3.4.1 说明服务器(Help Server)............................................................................................................... 83
3.5 自动更新(Install/Update).......................................................................................................................... 84
3.6 Java ............................................................................................................................................................ 84
3.6.1 外观(Appearance)........................................................................................................................... 85
3.6.2 类别路径变量(Classpath variables)............................................................................................... 86
3.6.3 程序代码格式制作器(Code Formatter)......................................................................................... 86
3.6.4 程序代码产生(Code generation) ................................................................................................... 88
Eclipse 中文教程.doc 第 3 页,共 221 页
3.6.5 编译器(Compiler)........................................................................................................................... 90
3.6.6 Java 编辑器(Java editor) ............................................................................................................... 94
3.6.7 JRE 安装(JRE installations) .......................................................................................................... 99
3.6.8 JUnit.............................................................................................................................................. 100
3.6.9 新专案(New project) .................................................................................................................... 100
3.6.10 组织汇入(Organize imports) ...................................................................................................... 101
3.6.11「重构」喜好设定(Refactoring preferences)............................................................................. 102
3.6.12 作业标示(Task Tags).................................................................................................................. 102
3.7 团队(Team).............................................................................................................................................. 102
3.7.1 CVS .............................................................................................................................................. 103
3.7.2 忽略的资源(Ignored Resources).................................................................................................. 107
3.7.3 档案内容(File Content)................................................................................................................ 107
4. Java程序开发.................................................................................................................................................... 108
4.1 建立Java项目.......................................................................................................................................... 108
4.2 建立Java类别.......................................................................................................................................... 110
4.3 程序代码完成功能 ..................................................................................................................................111
4.3.1 Code Completion ...........................................................................................................................111
4.3.2 Code Assist ....................................................................................................................................111
4.4 执行Java程序.......................................................................................................................................... 112
4.5 Java实时运算簿页面(Java Scrapbook Page).......................................................................................... 114
4.6 自订开发环境 ......................................................................................................................................... 121
4.6.1 程序代码格式 .............................................................................................................................. 121
4.6.2 程序代码产生模板 ...................................................................................................................... 122
4.6.3 Javadoc批注 ................................................................................................................................. 124
4.7 产生 getter 与 setter.............................................................................................................................. 128
4.8 建立 JAR 档案...................................................................................................................................... 130
4.8.1 建立新的 JAR 档案 ................................................................................................................... 130
4.8.2 设定进阶选项 .............................................................................................................................. 132
4.8.3 定义 JAR 檔的 manifest............................................................................................................ 133
4.8.4 重新产生 JAR 檔 ....................................................................................................................... 135
4.9.建立 Javadoc 文件 ................................................................................................................................137
4.9.1 选取产生 Javadoc 用的类型...................................................................................................... 137
4.9.2 为标准 doclet 配置 Javadoc 自变量........................................................................................ 138
4.9.3 配置 Javadoc 自变量.................................................................................................................. 138
4.10 工作集(Working Sets) ........................................................................................................................... 139
4.10.1 新增工作集 ................................................................................................................................139
4.10.2 隐藏「导览器」视图中的档案 ................................................................................................ 141
4.10.3 显示「导览器」视图中的档案 ................................................................................................ 142
Eclipse 中文教程.doc 第 4 页,共 221 页
5.除错.................................................................................................................................................................... 144
5.1 错误的程序 ............................................................................................................................................. 144
5.2 设定岔断点(Breakpoints) ....................................................................................................................... 145
5.3 逐步除错 ................................................................................................................................................. 149
5.3.1 Step Into........................................................................................................................................ 149
5.3.2 Step Over ...................................................................................................................................... 149
5.3.3 Step Return ................................................................................................................................... 149
5.3.4 Drop to Frame............................................................................................................................... 149
5.3.5 Use Step Filters/Step Debug ......................................................................................................... 150
5.4 继续执行 ................................................................................................................................................. 151
5.5 设定岔断点的Hit Count ......................................................................................................................... 153
5.6 岔断点组态设定 ..................................................................................................................................... 160
5.7 监视点(Watchpoint) ................................................................................................................................161
5.8 方法岔断断点(Method Breakpoint)........................................................................................................ 164
5.9 异常岔断点(Exception Breakpoint)........................................................................................................ 166
5.10 Java表示式及变更某些值 .................................................................................................................... 168
6.重构(Refactoring)............................................................................................................................................... 170
6.1 重新命名 ................................................................................................................................................. 170
6.1.1 区域变量(Local Variable) ............................................................................................................ 170
6.1.2 字段(Field) ................................................................................................................................... 171
6.1.3 方法(Method) ............................................................................................................................... 173
6.1.4 类别(Class)或是接口(Interface) .................................................................................................. 174
6.1.5 套件(Package) .............................................................................................................................. 176
6.2 撷取(Extracting)...................................................................................................................................... 177
6.2.1 撷取常数(Extracting a Constant) ................................................................................................. 177
6.2.2 撷取区域变量(Extracting a Local Variable) ................................................................................ 180
6.2.3 撷取方法(Extracting a Method)................................................................................................... 182
6.3 列入(Inlining).......................................................................................................................................... 187
6.3.1 列入常数(Inlining a Constant) ..................................................................................................... 187
6.3.2 列入区域变量(Inlining a Local Variable) .................................................................................... 189
6.3.3 列入方法(Inlining a Method)....................................................................................................... 191
6.4 变更方法签章(Signature) ....................................................................................................................... 193
6.5 移动Java元素(Moving Java Elements) ................................................................................................... 196
6.5.1 字段(Field) ................................................................................................................................... 197
6.5.2 Static Members ............................................................................................................................. 198
6.6 自行封装字段(Self Encapsulating a Field)............................................................................................. 200
7.要诀和技巧(Tips and Tricks)............................................................................................................................. 203
7.1 编辑程序文件(Editing Source)............................................................................................................... 203
Eclipse 中文教程.doc 第 5 页,共 221 页