1. Trang chủ
  2. » Công Nghệ Thông Tin

Sách Java dành cho người mới học

32 192 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 32
Dung lượng 1,57 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Sách Java dành cho người mới học , Sách Java dành cho người mới học , Sách Java dành cho người mới học , Sách Java dành cho người mới học , Sách Java dành cho người mới học , Sách Java dành cho người mới học , Sách Java dành cho người mới học ,Sách Java dành cho người mới học Sách Java dành cho người mới học Sách Java dành cho người mới học

Trang 1

Java Programing

Language

SESSION 01 – Introduction to Java

Trang 2

• Choosing a development environment

• Writing a simple Java program

• Using the command-line tools

• Using Java NetBeans and Eclipse

Trang 3

– Originally called Oak

• Aimed at producing an operating environment for networked devices and embedded systems

– “Write once, run anywhere”

– Java is currently one of the most popular

programming language

Trang 4

The Java history timeline

Trang 5

Java Virtual Machine

• Java is both a compiled and an interpreted language

– Source code is compiled into Java bytecode

– bytecode is then interpreted by the J ava V irtual M achine

(JVM)

Trang 6

Java Virtual Machine (cont)

Java Code

Byte Code (.class)

JVM

Trang 7

Java language for Mobile application development

• Android (Java)

• Bada (C++)

• Black Berry (Java)

• iPhone, iPad (Objective-C)

Trang 9

Features of Java (cont)

• Simple :

– The syntax is mostly derived from C and C++

– Java has simplified C++ programming by remove some of complicated and difficult from C++

Trang 10

Features of Java (cont)

– Java’s support for Object-Orientation includes

inheritance, polymorphism, data access levels…– Not support multiple inheritance

Trang 11

Features of Java (cont)

• Platform-independent :

– Java was conceived with the concept of WORA:

“Write once, Run anywhere"

– Java code (.java) is compiled a byte code which is independent of the system

– Java byte code (.class) can run on any device

equipped with a Java Virtual Machine

Trang 12

Features of Java (cont)

• Robust : Java can be used to solve some very complex programming problems with the

Trang 13

Features of Java (cont)

• Secure :

– No pointers are forged

– No illegal object casts are performed

– There will be no operand stack overflows or underflows

– All parameters passed to functions are of the proper types

– Rules regarding private, protected, and public class membership are followed

Trang 14

Features of Java (cont)

• Multi-threaded:

– Multiple, synchronized threads is built directly into the

Java language and runtime environment

– Synchronized threads are useful in creating distributed, network-aware applications

Trang 15

Java compared with other languages

Trang 16

The popularity of Java

Trang 17

JDK and JRE

• The two principal products in the Java SE

platform: J ava Development Kit (JDK) and Java

Runtime Environment (JRE).

– The JRE provides the libraries, Java virtual machine,

and other components necessary for running applets

and applications written in the Java programming

language

– The JDK includes the JRE plus development tools such

as compilers and debuggers that are necessary or

useful for developing applets and applications

Trang 18

JDK and JRE

Trang 19

Download and install JDK

• The JDK is a development environment for building applications, applets, and components using the Java programming language.

• JDK can be download at http://www.oracle.com

• After downloading the JDK, follow the

platform-dependent installation directions At the time of this writing, they were available at

http://java.sun.com/javase/6/webnotes/install/ind ex.html.

Trang 20

Navigating the Java Directories

• The JDK has the directory structure shown

Trang 21

Setting the Execution Path

1 Click Start > Control Panel > System on

Windows XP or Start > Settings > Control

Panel > System (on Windows XP.)

2 Click Advanced > Environment Variables.

3 Add the location of bin folder of JDK

installation for PATH in User Variables and

System Variables A typical value for PATH is:

C:\Program Files\Java\jdk1.6.0_<version>\bin

Trang 22

Write a simple Java program

The first application will simply display the greeting "Hello world!"

• Step 1: Create a source file

public class Helloworld

• Step 2: Compile the source file into a class file

• Step 3: Run the program

Trang 23

Write a simple Java program

Write Java

code using

an editor

javac Helloworld.java

This creates a file of bytecode with a

.class extension

Trang 24

Using the Command-Line Tools

• Open a shell indow Go to directory where you

store your Helloworld.java and use javac

Trang 25

Using the Command-Line Tools

• The javac has a set of standard options:

Trang 26

Choosing a Development Environment

• NetBeans

• Jbuilder

• Eclipse

Trang 27

Using Java NetBeans

Trang 28

• Create a Java Project:

Using NetBeans

Trang 29

• Write a simple program:

Using NetBeans

Trang 30

• Program’s output in Console window:

Trang 31

• Java has three ways of marking comments:

– The most commonmethod is a //

– Use the /* and */ comment to block off a longer comment

Trang 32

• In this session, we learnt:

– History of Java

– Java Virtual Machine

– Types of Java programs

– Features of Java

– JRE and JDK

– Choosing a development environment – Writing a simple Java program

– Using the command-line tools

– Using Java NetBeans and Eclipse

– Basic of Java

Ngày đăng: 12/06/2018, 23:04

TỪ KHÓA LIÊN QUAN

w