Tải bản đầy đủ (.pdf) (40 trang)

Bài giảng Phát triển phần mềm mã nguồn mở: IDE và SDK

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.7 MB, 40 trang )

IDE và SDK
Phát triển phần mềm mã nguồn mở


Nội dung
• Giới thiệu Eclipse
• Android SDK
• Zend Studio


Giới thiệu Eclipse


Giới thiệu Eclipse
• Eclipse là IDE mã nguồn mở
• Cung cấp công cụ để soạn thảo code, biên dịch, và
debug.
• Đầu tiên chỉ thiết kế riêng cho Java, nhưng nay đã hỗ trợ
cho nhiều ngôn ngữ khác.
– Hỗ trợ tốt cho C, C++
– Python, PHP, Ruby, v.v…

• Cần phải cài JDK để chạy Eclipse
• Eclipse có thể được tải về từ…
– />– Cần chọn “Eclipse IDE for Java Developers”


Cài đặt Eclipse
• Giải nén file zip vào một thư mục nào đó.
• Trên windows
– Thường giải nén vào thư mục C:\eclipse\


– Rồi tạo shortcut trên desktop để thi hành
Eclipse
• C:\eclipse\eclipse.exe

• Trên Linux
– Giải nén vào /opt/eclipse/


Chọn Workspace
• Với Eclipse, toàn bộ mã nằm trong workspace
• Một workspace chỉ là nơi cất giữ mã nguồn
• Eclipse cho phép có nhiều workspaces – mỗi workspace
được thiết kế theo cách riêng
• Chọn nơi muốn lưu trữ file, rồi nhấp OK


Welcome to Eclipse
• Lần đầu tiên làm việc
với Eclipse, ta sẽ thấy
màn hình.
• Từ đây ta có thể xem
khái quát về platform,
tài liệu hướng dẫn,
code mẫu, v.v…
• Nhấp vào mũi tiên bên
phải để lấy IDE


Các thành phần Eclipse IDE
Perspective Switcher

Menubars
Full drop down menus plus quick
access to common functions

We can switch between
various perspectives
here

Task List Pane
This contains a list of
“tasks” to complete

Editor Pane
This is where we edit
our source code
Package Explorer Pane

Outline Pane

This is where our
projects/files are listed

This contains a hierarchical
view of a source file
Miscellaneous Pane
Various components can appear in this
pane – typically this contains a console
and a list of compiler problems



Tạo Project mới
• To create a project: File  New  Java Project


Tạo Project mới


Thư mục src
• Eclipse tự động tạo thư mục src để chứa mã


Tạo Class
• Nhấp vào nút New, rồi chọn Class


Class mới được tạo

Directory structure for
package and actual java file
created automatically

Source is loaded into the
editor pane, already
stubbed out

Source displayed in a
hierarchical fashion listing
each method name



Biên dịch mã nguồn
• Eclipse tự động biên dịch mã nguồn

Position in file is
marked with a red
line – 1 click allows
you to jump to line
with error

Packages/Classes
with errors are
marked with a red X

Often Eclipse may have
suggestions on how to fix the
problem – if so, a small light
bulb will be displayed next to the
line of offending code

Error underlined with red
squiggly line (just like
spelling errors in many
word processors)

Methods with
errors are marked
with a red X

The Problems tab will contain a
tabular representation of all errors

across all files of all open projects


Biên dịch mã nguồn
• Eclipse đề nghị thay printn thành print hay println


Running Code
• Nhấp phải vào class rồi chọn Run As  Java
Application


Running Code
• Kết quả xuất hiện trên Console tab


Re-Running Code


Debugging Code
• Eclipse có bộ gỡ rối đẹp
• Set break points ở lề bên trái


Debugging Code
• Nhấp phải vào class và chọn Debug As  Java
Application


Debugging Code

• Lần đầu tiên debug sẽ thấy dialog sau


Quan sát Debug

Note new Debug
perspective – click Java to
return to normal

These buttons allow you
to step through the code

Variables in scope are listed here along
with their current values (by right
clicking you can change values of
variables as you program is running)

List of breakpoints

This pane shows the current
line of code we broke on
Current high level location
(class and method)

Output console, just like
in normal run mode


Android Tools
• Phone

• Eclipse (

/>
)

– Android Plugin (ADT)

• Android SDK (

)
• Windows Users: cần cài đặt Motorola
Driver trực tiếp ( />
EN/Support-Homepage/Software_and_Drivers/USB-and-PC-

Charging-Drivers

)


Android SDK
• Mỗi lần cài là mở trình SDK Manager
• Cài các gói cần thiết
• Tạo thiết bị ảo Android Virtual Device
(AVD)


SDK Manager



×