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

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

Đ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

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

Java Programing Language SESSION 01 – Introduction to Java OBJECTIVES • • • • • • • • History of Java Java Virtual Machine 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 History of Java • Developed and maintained by Sun MicroSystems (Oracle - 2010) – Since 1991 – James Gosling – 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 The Java history timeline • • • • • • • • • • • 1991: Oak Language 1995: Name changed from Oak to Java 1996: JDK 1.0 1997: JDK 1.1 1998: J2EE, J2SE, J2ME 2000: J2SE(EE) 1.3 2002: J2SE(EE) 1.4 2004: J2SE(EE) (1.5) 2006: Java SE(EE) 2008: JavaFX 1.0 2011: Java SE J2ME J2SE J2EE 6.0 7.0 1.0 1.1 1.4 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 Java Virtual Machine (JVM) Java Virtual Machine (cont) Java Code Byte Code (.class) JVM Windows Linux Mac Java language for Mobile application development • • • • • • • • • Android (Java) Bada (C++) Black Berry (Java) iPhone, iPad (Objective-C) Java Me (Java) WebOs (C , C++, Javascript, HTML) Symbian (C++) Windows Mobile (VC++,C++) Windows Phone (C#) Features of Java • • • • • • • Simple Object-Oriented Platform-independent Robust Secure Distributed Multi-threaded 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++ • • • • • • Goto statement Overload operator Pointer Header Union, struct … Features of Java (cont) • Object-Oriented: – Except for primitive data types, everything in Java is an object – There are no global functions in Java: all functions are invoked through an object – Java’s support for Object-Orientation includes inheritance, polymorphism, data access levels… – Not support multiple inheritance JDK and JRE 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 platformdependent installation directions At the time of this writing, they were available at http://java.sun.com/javase/6/webnotes/install/ind ex.html Navigating the Java Directories • The JDK has the directory structure shown below: JDK 1.6.0_ LICENSE demo lib COPYRIGHT jre include README.txt Readme.html bin bin lib Setting the Execution Path Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System (on Windows XP.) Click Advanced > Environment Variables 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_\bin Write a simple Java program The first application will simply display the greeting "Hello world!" • Step 1: Create a source file public class Helloworld { public static void main(String[] args) { System.out.println("Hello world"); } } • Step 2: Compile the source file into a class file • Step 3: Run the program Write a simple Java program Write Java code using an editor Text Editor Run the Java compiler 'javac' Save the file with a java extension Java code: Helloworld.java javac Helloworld.java This creates a file of bytecode with a class extension Bytecode: Helloworld.class Execute the bytecode with the command 'java' java Helloworld Output Using the Command-Line Tools • Open a shell indow Go to directory where you store your Helloworld.java and use javac Using the Command-Line Tools • The javac has a set of standard options: – – – – – – – – – – classpath classpath d directory encoding encoding g help nowarn source release sourcepath sourcepath target version … Choosing a Development Environment • NetBeans • Jbuilder • Eclipse Using Java NetBeans Using NetBeans • Create a Java Project: Using NetBeans • Write a simple program: Using NetBeans • Program’s output in Console window: Comments • Java has three ways of marking comments: – The most commonmethod is a // – Use the /* and */ comment to block off a longer comment Summary • 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 ... Write a simple Java program Write Java code using an editor Text Editor Run the Java compiler 'javac' Save the file with a java extension Java code: Helloworld .java javac Helloworld .java This creates... 2006: Java SE(EE) 2008: JavaFX 1.0 2011: Java SE J2ME J2SE J2EE 6.0 7.0 1.0 1.1 1.4 Java Virtual Machine • Java is both a compiled and an interpreted language – Source code is compiled into Java. .. Java and C# • Java and script language such as PHP, Perl, Python, Ruby • Java and JavaScript The popularity of Java JDK and JRE • The two principal products in the Java SE platform: Java Development

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

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan