Introduction to Java - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Java

Description:

Introduction to Java Programming Paradigms Computing in the 1990s The Internet and the WWW Graphical User Interfaces (GUIs) Object-oriented Programming (OOP) The ... – PowerPoint PPT presentation

Number of Views:111
Avg rating:3.0/5.0
Slides: 16
Provided by: JPV6
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Java


1
Introduction to Java
  • Programming Paradigms

2
Computing in the 1990s
  • The Internet and the WWW
  • Graphical User Interfaces (GUIs)
  • Object-oriented Programming (OOP)

3
The Internet
  • A global network of computers
  • The World Wide Web (WWW)
  • users retrieve documents
  • remote programs may be invoked
  • Need language platforms that are
  • network-aware
  • portable
  • secure

4
Graphical User Interfaces
  • Users interact with an application through visual
    objects
  • Windows, Buttons, Text fields, etc.
  • Mouse and pointer facilitate certain actions
  • click, drag, drop, etc.
  • Visual Programming
  • focus is on handling UI objects and events

5
Object-Oriented Programming
  • Program (revised definition)
  • collection of interacting objects
  • Object
  • a thing that has identity, state, and behavior
  • instance of a class
  • OOP
  • focus is on developing classes that specify state
    (variables) and behavior (functions)

6
Enter Java
  • 1991
  • Sun Microsystems develops a language (based on C)
    for consumer electronic devices
  • 1993
  • WWW explodes in popularity
  • increased need for dynamic Web pages
  • 1995
  • Sun formally announces Java for web use

7
What is Java?
  • Java is a general purpose programming language
    that is
  • object-oriented
  • interpreted, architecture-neutral, portable
  • distributed (network-aware), secure
  • simple, robust
  • multi-threaded
  • high-performance (?)

8
Two Types of Java Programs
  • Applications
  • general-purpose programs
  • standalone
  • executed through the operating system
  • Applets
  • programs meant for the WWW
  • embedded in a Web page
  • normally executed through a browser

9
Simple Java Application
  • File Hello.java
  • // Hello World application
  • public class Hello
  • public static void main(String args)
  • System.out.println(Hello world)

10
Compilation and Execution
  • Compile using javac (compiler)
  • Cgt javac Hello.java
  • Hello.class file is produced
  • Execute using java (interpreter)
  • Cgtjava Hello
  • requires a Hello.class file

11
Simple Java Applet
  • File HelloAgain.java
  • import java.awt.
  • import java.applet.Applet
  • public class HelloAgain extends Applet
  • public void paint(Graphics g)
  • g.drawString(Hello,50,50)

12
Executing Applets
  • After compiling the java program
  • Embed an applet tag in an .html document that
    references the .class file
  • Open the .html document using a browser or the
    appletviewer

13
Sample .html Document
  • File HA.html
  • lth1gt My First Applet lt/h1gt
  • ltapplet codeHelloAgain.class height200
    width100gt
  • lt/appletgt

14
What is HTML?
  • Hypertext Markup Language
  • Underlying language of Web pages
  • A means of providing formatting instructions for
    presenting content
  • Text-based
  • .html documents
  • collection of content and controls (tags)

15
Java Program Structure
  • Java Program
  • (optional) import declarations
  • class declaration
  • Class
  • class name should match its file name
  • may extend an existing class (such as Applet)
  • contains method/function declarations
Write a Comment
User Comments (0)
About PowerShow.com