Top Banner
Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 [email protected]
30

Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 [email protected].

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Programming Software Applications

Week 1

Dr. Xiaohong GaoTrent Park – B107, ext.

2252

[email protected]

Page 2: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Course Objectives (1/2)

Upon completing the course, you will understand :• Java applications• Primitive data types• Java control flow• Methods• Object-oriented programming• Inheritance• Polymorphism• Core Java classes (Swing)• Graphics

Page 3: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Course Objectives (2/2)

You will be able to :

Write applications

Develop a simple GUI interface

Write interesting projects

Establish a firm foundation on Java concepts

Page 4: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Learning Patterns

•Lecturer(1.5 hours): theory with sample programs

•Labs (1.5 hours) : Practice theory using Java programs

•Workshops/seminars: discussion/reflection

Page 5: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Assessment Pattern

• Exam (3 hours) ---- 70

Course work ---- 30%

2 Mini-tasks

10%

Project

20%

Note: You have to pass both coursework and exam in order to pass the module.

Page 6: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Contact Information

• Duty tutor time» Friday, 12:30-13:30, Bevan Building

[email protected]

• Learning Materialshttp://www.cs.mdx.ac.uk/staffpages/xiaohong/cmt4001

Page 7: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Introduction to Java

Objectives

What Is Java?

• Getting Started With Java Programming

• Compiling and Running a Java Application

• Compiling and Running a Java Applet

Page 8: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Example 1 --- Using TextPad

Page 9: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

2. File New

3. File Save As Hello1.java

Page 10: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

3. Tools Compile Java

Page 11: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

4. Tools Run Java Application

Page 12: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

What Is Java?

• History

• Characteristics of Java

Page 13: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

History

• James Gosling

Oak

• Java, May 20, 1995, Sun World

• HotJava – The first Java-enabled Web browser

Page 14: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Characteristics of Java

• Java is simple• Java is object-oriented

• Java is distributed

• Java is interpreted

• Java is robust

• Java is secure

Page 15: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Characteristics of Java

• Java is architectural-neutral

• Java is portable

• Java’s performance

• Java is multithreaded

• Java is dynamic

Page 16: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

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)

• Java 2 SDK v 1.4

Page 17: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Java IDE Tools

• Inprise JBuilder (RAD) (www.inprise.com)

• Microsoft Visual J++ (www.microsoft.com)

• Visual Café by WebGain (www.webgain.com)

• JFactory by Rouge Wave (www.rougewave.com)

• Forte by Sun (www.javasoft.com)

• IBM Visual Age for Java (RAD) (www.ibm.com)

Page 18: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Getting Started with Java Programming

• A Simple Java Application

Compiling Programs

Executing Applications

• A Simple Java Applet

Viewing Java Applets

• Applications vs. Applets

Page 19: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

A Simple Application

Example:

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

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

Page 20: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Compiling Programs

• On command line– javac file.java

Page 21: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Executing Applications

• On command line– java classname

JavaInterpreter

on Windows

JavaInterpreter

on Sun Solaris

JavaInterpreteron Linux

Bytecode

...

Page 22: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Example

javac Welcome.java

java Welcome

output:...

Page 23: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

A Simple Applet (Optional)

Example

/* This is an example of Java applets */ import java.awt.Graphics;

public class WelcomeApplet extends java.applet.Applet { public void paint (Graphics g) {

g.drawString("Welcome to Java!",10,10);

}}

Page 24: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Creating an HTML File

<html><body><applet code="WelcomeApplet.class" width = 100 height = 40></applet></body></html>

Page 25: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Viewing Java Applets

Page 26: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Applet Viewer Utility

appletviewer htmlfile.html

Example:

appletviewer WelcomeApplet.html

Page 27: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Applications vs. Applets

• Similarities

• Differences

Page 28: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Security Restrictions on Applets

• Applets are not allowed to read from, or write to, the file system of the computer viewing the applets.

• Applets are not allowed to run any programs on the browser’s computer.

• Applets are not allowed to establish connections between the user’s computer and another computer except with the server wherethe applets are stored.

Page 29: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Java books

• Dietel & Dietel

“Advanced Java 2 Platform -How to program”Prentice Hall,last edition

•Judith Bishop

“Java Gently,Third edition,Addison-Wesley”

Page 30: Programming Software Applications Week 1 Dr. Xiaohong Gao Trent Park – B107, ext. 2252 x.gao@mdx.ac.uk.

Summary

• Introduction to the module

• Java characteristics