Comp2513 Java and Applets Daniel L. Silver, Ph.D..

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

In Review JAVA C++ GUIs - Windows Webopedia.com.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
MC697 Object-Oriented Programming Using Java. In this class, we will cover: How the class will be structured Difference between object-oriented programming.
Java Applet & JavaScript SNU OOPSLA Lab. October 2005.
The Java Language. Topics of this Course  Introduction to Java  The Java Language  Object Oriented Programming in Java  Exceptions Handling  Threads.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Object Orientated Programming
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Introduction to Java Kiyeol Ryu Java Programming Language.
Comp2513 E-Commerce Infrastructure 2 Daniel L. Silver, Ph.D.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
CMSC 202 Computer Science II for Majors Fall 2009 Introduction.
COMP Computer Basics Yi Hong May 13, 2015.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Applets & Servlets.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
1 COMM 1213 H1 COMP 4923 X1 Advanced HTML & Introduction to Computer Programming (Readings: Ch. 8, 9 Knuckles)
Java Beserkers Group 4. Start of Java Development began on June of 1991 by a group of computer scientist at the Sun Mircrosystems Company Development.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Introduction to Java Programming with Forte Y. Daniel Liang.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
Java applets. Outline What is Java? Java Applications Java Applets Java Applets Securities Summary.
Session 1 Introduction to Java. Objectives Java Simplified / Session 1 / 2 of 32 Explain the history of Java Explain Java in brief List the types of Java.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
 Programming Language  Object Oriented Programming  JAVA – An Introduction  JAVA Milestones  JAVA Features.
10/8: Software What is software? –Types of software System software: Operating systems Applications Creating software –Evolution of software development.
CT1513 Introduction To java © A.AlOsaimi.
Software Development Programming & Languages. Programming: A Five-Step Procedure Define the problem Design a solution Code the program Test the program.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java -- A very Hot Object- Oriented Language Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of.
1 Applets are small applications that are accessed on an Internet server, transported over the internet, automatically installed and run as a part of web.
What is Java? Object Oriented Programming Language Sun Microsystems “Write Once, Run Everywhere” Bytecode and Virtual Machine Java Platform (Java VM and.
Java – in context Main Features From Sun Microsystems ‘White Paper’
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
1 Introduction to Java. 2 * 10% Assignments/ class participation * 10% Pop Quizzes * 05% Attendance * 25% Mid Term * 50% Final Term.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
JAVA PROGRAMMING Buzzwords. Simple: Less complex syntax than C++ Not as easy to design as Visual Basic Small size of interpreter.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Chapter 1 Coding Introduction.
Computer System Structures
Applications Active Web Documents Active Web Documents.
Chapter 1 Introduction to Computers, Programs, and Java
Lecture 1: Introduction to JAVA
Introduction to Computers and Java
Java programming lecture one
Introduction to Java Dept. Business Computing University of Winnipeg
Introducing Java.
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Comp2513 Java and Applets Daniel L. Silver, Ph.D.

2001Daniel L. Silver2 Objectives To introduce the Java programming language and its fit with the Web To introduce the Java programming language and its fit with the Web To discuss the use of Applets as a part of the E-Commerce infrastructure To discuss the use of Applets as a part of the E-Commerce infrastructure References: Chapter 3 References: Chapter 3

2001Daniel L. Silver3 Outline Java an Object Oriented Programming language Java an Object Oriented Programming language Why Java and the Web? Why Java and the Web? Java Applets Java Applets

2001Daniel L. Silver4 Programming Languages A programming language adheres to a specified syntax that is accepted by either an interpreter or a compiler. A programming language adheres to a specified syntax that is accepted by either an interpreter or a compiler. What is the difference between an interpreter and a compiler? What is the difference between an interpreter and a compiler? Basic code InterpreterCompiler C code Operating System Computer Hardware *.exe

2001Daniel L. Silver5 Function-Oriented Programming Traditional programming languages are known as function-oriented. Why? Traditional programming languages are known as function-oriented. Why? –Consider the movement of data from function to function –Data and processing are considered separately What are some examples of function-oriented languages? What are some examples of function-oriented languages? –COBOL –Basic –Fortran –C–C–C–C Prone to misuse of data and process elements Not supportive of encapsulation, cohesion and loose coupling

2001Daniel L. Silver6 Object-Oriented Programmng Combines data and processes together into objects Combines data and processes together into objects An object is an entity that can contain data (attributes, properties) and can manipulate data using functions (methods) An object is an entity that can contain data (attributes, properties) and can manipulate data using functions (methods) An object has state and behaviour An object has state and behaviour What are some examples of OO lang.? What are some examples of OO lang.? A simple example … Hello_app.java A simple example … Hello_app.java Attributes Methods

2001Daniel L. Silver7 Java: An OOP Language Java is a relatively new language Java is a relatively new language “Green”, 1991 Sun Microsystems – dev. for use in consumer devices such as intelligent TV controllers “Green”, 1991 Sun Microsystems – dev. for use in consumer devices such as intelligent TV controllers –Object Oriented but simpler than C++ –Architecture neutral –Real-time remote applications –Portable, Reliable and Secure

2001Daniel L. Silver8 Java and the Java Virtual Machine program.class Java Virtual MachineCompiler program.java Operating System Computer Hardware

2001Daniel L. Silver9 Java Translation and Execution Java source code Java compiler Java (JVM) Interpreter Bytecode compiler Java bytecode Machine code hello_app.java hello_app.class hello_app.exe Efficient because of bytecode javac java

2001Daniel L. Silver10 Java and the Web In 1995 the first HotJava browser was demoed at SunWorld exhibition In 1995 the first HotJava browser was demoed at SunWorld exhibition It could download programs called applets from a the web and run them locally It could download programs called applets from a the web and run them locally Provided animation and interaction Provided animation and interaction “Write once, run anywhere” “Write once, run anywhere” By 1996 both Netscape and MS supported Java within their browsers By 1996 both Netscape and MS supported Java within their browsers

2001Daniel L. Silver11 Java and the Web Java has been designed for the Web Java has been designed for the Web It has two attributes that make it suitable: It has two attributes that make it suitable: –Security: An assortment of security features that guarantee that no evil applets can be written and assist in the writing of good code –Portability: Applications and Applets can run on Windows, Unix, Linux, Mac, IBM mid- range and mainframe

2001Daniel L. Silver12 Java Applet Security Programs that come from over the network can be malicious (destroy data on your PC) Programs that come from over the network can be malicious (destroy data on your PC) Java was designed to prevent malicious behaviour Java was designed to prevent malicious behaviour Two primary safety features: Two primary safety features: –Signatures – an applet can be signed and a browser can be set up to accept only trusted applet authors –Secuirty Priviledges – by default an applet runs in the “sandbox” where I/O is limited to the keyboard/mouse and the display, trusted applets can be give higher level priveledges (e.g. disk I/O )

2001Daniel L. Silver13 Java and the Web Reasons why Java has become the fastest growing programming language of all time: Reasons why Java has become the fastest growing programming language of all time: –It is an object-oriented language –Contains a vast library of software (object classes and methods) »Java Development Kit (J2SE SDK) »Objects that have been developed and tested »Imported for use at the beginning of a program –A good first language to learn... Why?

2001Daniel L. Silver14 Java Applications vs Applets There are two classes of Java programs: Applications - such as Hello_app.java Applications - such as Hello_app.java –I/O is by default with console and character oriented –Graphical I/O is an option that is commonly taken Applets – as we shall see Applets – as we shall see –Run by a Web browser using an imbedded Java interpreter –Graphical I/O – characters, diagrams

2001Daniel L. Silver15 Java Translation and Execution Java source code Java compiler Java applet bytecode Interne t Java (JVM) Interpreter Web Browser Client Server abc.java abc.class HTTP Server App Server

2001Daniel L. Silver16 Java Applets A Simple Example: HelloApplet.java / HelloApplet.html … HelloApplet.java / HelloApplet.html … HelloApplet.javaHelloApplet.html HelloApplet.javaHelloApplet.html Nothing is passed to the applet from the HTML Nothing is passed to the applet from the HTML Anatomy of an Applet – fundamental methods: Anatomy of an Applet – fundamental methods: –init() – invoked once when applet is first loaded –start() – invoked each time applet becomes visible –stop() – invoked each time applet becomes invisible –paint() – display of text and graphics –destroy() – invoked once when applet is exited

2001Daniel L. Silver17 Java Applets Parameter Passing Example: FirstApplet.java / FirstApplet.html … FirstApplet.java / FirstApplet.html … FirstApplet.javaFirstApplet.html FirstApplet.javaFirstApplet.html tag is used to pass parameters from HTML to Java program at run time tag is used to pass parameters from HTML to Java program at run time has two attributes: has two attributes: –NAME - name of parameter being passed –VALUE – value of parameter being passed -e.g.:

2001Daniel L. Silver18 Java Applets The Graphics object class allows you to do many things: The Graphics object class allows you to do many things: –setColor() –fillRect() –drawLine() –drawRect() –drawOval() –drawImage()

2001Daniel L. Silver19 Java Applets Threads and Event Handling Example: AnimationApplet.java / AnimationApplet.html … AnimationApplet.java / AnimationApplet.html … AnimationApplet.java AnimationApplet.html AnimationApplet.java AnimationApplet.html Thread – a portion of a Java program that executes independently, e.g.: Thread – a portion of a Java program that executes independently, e.g.: –Thread 1 - allows animation to occur on the browser window –Thread 2 – captures input from the keyboard

2001Daniel L. Silver20 Java Applets Threads and Event Handling Example: Event Handling is used within programs to associate events such as mouse clicks to revelent portions of code Event Handling is used within programs to associate events such as mouse clicks to revelent portions of code In AnimationApplet.java a mouseDown() event is used to start and stop the scrolling message In AnimationApplet.java a mouseDown() event is used to start and stop the scrolling message

2001Daniel L. Silver21 Java Applets A more advanced example – link.html A more advanced example – link.htmllink.html –Provides sources of further information on Java and Applets Notice how in link.java: Notice how in link.java:link.java – is used in this example –showDocument(theURL,targetFrame) is used to link to a URL

THE END