Download - Introduction to Java Programming with JBuilder 4

Transcript
Page 1: Introduction to Java Programming with JBuilder 4

Introduction to

Java Programming with JBuilder 4

Y. Daniel Liang

Page 2: Introduction to Java Programming with JBuilder 4

Introduction

Course Objectives Organization of the Book

Page 3: Introduction to Java Programming with JBuilder 4

Course Objectives Upon completing the course, you will understand

– Create, compile, and run Java programs– Primitive data types– Java control flow– Methods– Arrays– Object-oriented programming– Core Java classes (Swing, exception,

internationalization, multithreading, multimedia, I/O, networking, Java Collections Framework)

Page 4: Introduction to Java Programming with JBuilder 4

Course Objectives, cont.

You will be able to – Write applications and applets– Develop a GUI interface– Write interesting projects– Establish a firm foundation on Java concepts

Page 5: Introduction to Java Programming with JBuilder 4

Book Chapters Part I: Fundamentals of Programming

– Chapter 1 Introduction to Java

– Chapter 2 Primitive Data Types and Operations

– Chapter 3 Control Statements

– Chapter 4 Methods

– Chapter 5 Arrays

Page 6: Introduction to Java Programming with JBuilder 4

Book Chapters, cont. Part II: Object-Oriented Programming

– Chapter 6 Programming with Objects and Classes

– Chapter 7 Strings

– Chapter 8 Class Inheritance and Interfaces

– Chapter 9 Object-Oriented Software Development

Page 7: Introduction to Java Programming with JBuilder 4

Book Chapters, cont. Part III: Graphics Programming

– Chapter 10 Getting Started with Graphics

Programming

– Chapter 11 Creating User

Interfaces

– Chapter 12 Applets and Advanced

Graphics

Page 8: Introduction to Java Programming with JBuilder 4

Book Chapters, cont. Part IV: Developing Comprehensive Projects

– Chapter 13 Exception Handling

– Chapter 14 Internationalization

– Chapter 15 Multithreading

– Chapter 16 Multimedia

– Chapter 17 Input and Output

– Chapter 18 Networking

– Chapter 19 Java Data Structures

Page 9: Introduction to Java Programming with JBuilder 4

Chapter 1 Introduction to Java and JBuilder

What Is Java? Getting Started With Java Programming

– Create, Compile and Running a Java Application

Page 10: Introduction to Java Programming with JBuilder 4

What Is Java?

History

Characteristics of Java

Page 11: Introduction to Java Programming with JBuilder 4

History

James Gosling

Oak

Java, May 20, 1995, Sun World

HotJava – The first Java-enabled Web browser

Page 12: Introduction to Java Programming with JBuilder 4

Characteristics of Java Java is simple

Java is object-oriented

Java is distributed

Java is interpreted

Java is robust

Java is secure

Java is architecture-neutral

Java is portable

Java’s performance

Java is multithreaded

Java is dynamic

Page 13: Introduction to Java Programming with JBuilder 4

JDK Versions JDK 1.02 (1995) JDK 1.1 (1996) Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) Java 2 SDK v 1.3 (a.k.a JDK 1.2, 2000)

Page 14: Introduction to Java Programming with JBuilder 4

Java IDE Tools Inprise JBuilder

Microsoft Visual J++

Symantec Café

Forte by Sun MicroSystems

IBM Visual Age for Java

Page 15: Introduction to Java Programming with JBuilder 4

Getting Started with Java Programming

A Simple Java Application

Compiling Programs

Executing Applications

A Simple Java Applet

Viewing Java Applets

Applications vs. Applets

Page 16: Introduction to Java Programming with JBuilder 4

A Simple Application

Example 1.1//This application program prints Welcome

//to Java! public class Welcome { public static void main(String[] args) {

System.out.println("Welcome to Java!"); }}

RunRunSourceSource

Page 17: Introduction to Java Programming with JBuilder 4

Compiling Programs

On command line– javac file.java

Page 18: Introduction to Java Programming with JBuilder 4

Executing Applications

On command line– java classname

JavaInterpreter

on Windows

JavaInterpreter

on Sun Solaris

JavaInterpreteron Linux

Bytecode

...

Page 19: Introduction to Java Programming with JBuilder 4

Example

javac Welcome.java

java Welcome

output:...

Page 20: Introduction to Java Programming with JBuilder 4

JBuilder BasicsJBuilder IDE Interface

Create a JBuilder project

Create Java programs

Compile and run Java programs

Page 21: Introduction to Java Programming with JBuilder 4

JBuilder IDE Interface

Page 22: Introduction to Java Programming with JBuilder 4

Creating a JBuilder project

Choose File, New Project to display the project wizard

Page 23: Introduction to Java Programming with JBuilder 4

Creating a JBuilder project, cont.

Verify Project path, source path, backup path, outpath

Page 24: Introduction to Java Programming with JBuilder 4

Creating a JBuilder project, cont.

Optional project description

Page 25: Introduction to Java Programming with JBuilder 4

Creating a Java Program

Choose File, New Class to display the class wizard

Page 26: Introduction to Java Programming with JBuilder 4

Compiling and Running a Program

Where are the files stored in the directory?

c:\example

chapter1.jpr

chapter1.html

chapter1

Welcome.java

Welcome.class

chapter1 Welcome.java~1~

chapter2

.

.

.

Java source files and class files for Chapter 2

chapter19 Java source files and class files for Chapter 19

bak

chapter2 Backup files for Chapter 2

.

.

. chapter19 Backup files for Chapter 19