application architecture using java hong li. introduction developed by a team led by james gosling...

11
Application Architecture Using Java Hong Li

Upload: phebe-johns

Post on 19-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Application Architecture Using Java

Hong Li

Page 2: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Introduction

Developed by a team led by James Gosling at Sun Microsystem.

Originally called Oak, designed in 1991 Renamed Java in 1995, redesigned for developing

Internet Application Full-featured, general-purpose programming

language Java initially became attractive because Java

program can be run from a web browser. It is called applet

Java can also be used to develop application on the server side. Called Java servlets or JavaServer Page

Page 3: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Characteristics of Java

Java is simple Java is Object-Oriented Java is distributed. Distributed computing

involves several computers working together on a network.

Java is Interpreted. Programs are compiled into the Java Virtual Machine code called bytecode. The bytecode is machine-independent and can run on any machine that has a Java interpreter, which is part of the Java Virtual Machine (JVM)

Page 4: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Specification, API, JDK and IDE

The Java language specification is a technical definition of the language that includes syntax and semantics

API contains predefined classes and interfaces J2SE-Java 2 standard edition J2EE-Java 2 Enterprise Edition (server side

application) J2ME-Java 2 Micro edition (mobile devices)

Page 5: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Java Development Toolkit (JDK)

Sun releases each versions of J2SE with a Java Development Toolkit (JDK)

JDK consists of a set of separate programs for developing and testing Java program Jbuilder by Borland (www.borland.com) NetBean open source by Sun(www.netbeans.org) Sun One, a comercial vrsion of NetBeans by Sun Eclipse open source by IBM (www.eclipse.org)

These tools provide an integrated development environment (IDE) for rapidly developing Java programs.

Page 6: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Application and Applet

A Java program can be written in many ways.

Applications are standalone programs. It can be executed from any computer with a Java interpreter

Applets are special kind of Java programs that can run directly from a Java-compatible Web Browser

Page 7: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

A simple Java Program

Display message “Welcome to Java!”// this application program prints Welcome to

Java!// file name: Welcome.java public class Welcome{ public static void main(String [] args) { System.out.println(“Welcome to Java!”); }}

Page 8: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Class and methods

The class is essential Java construct. To program in Java, you must understand classes and be able to write and use them. A program is defined by using one or more classes.

System.out is known as the standard output object. println is a method in the object

Every Java application must have a user-declared main method that defines where the program begins. The Java interpreter executes the application by invoking the main method

Page 9: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Displaying text in a message dialog box

// file name: WelcomeDialog.java import javax.swing.JoptionPane; public class WelcomeDialog { public static void main(String[] args) { JOptionPane.showMessageDialog(null, “Welcome

to Java!”,”Example 2”,JOptionPane.INFORMATION_MESSAGE);

} }

Page 10: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Jbuilder

Start->program->Jbuilder->Jbuilder Creating project

File->new Project Give a name and select directory, then click next Keep all setting for path, then click next For simplicity, uncheck Enable source package

discovery and compilation Click finish

Page 11: Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed

Jbuilder continued

Create a Java program File->new class Give file name, check only public and generate

main method, uncheck others Click OK

Compile a Java program Project->make xxx.java

Execute a Java program Run-> xxx.java using default