COMP201 Java Programming - PowerPoint PPT Presentation

About This Presentation
Title:

COMP201 Java Programming

Description:

1996 Sun released Java 1.0, but it is not for serious application. ... 2004, released version 5.0 that updated the Java language in significant way. ... – PowerPoint PPT presentation

Number of Views:158
Avg rating:3.0/5.0
Slides: 27
Provided by: CSD149
Category:

less

Transcript and Presenter's Notes

Title: COMP201 Java Programming


1
COMP201 Java Programming
Topic 1 Introduction Readings Chapter 1
2
Outline
  • C, C, and Java
  • How Java is related to C and C
  • Advantages of Java
  • Writing good codes in Java is easier than in C or
    C
  • Java libraries (packages)
  • Where the power of Java come from
  • Java and the internet
  • What Java is good for
  • Course content

3
C, C, and Java
  • C designed in 1970s for operating system
    programming, i.e. UNIX
  • High-level language compared with assembly
    language
  • Low-level compared with C or java
  • Low level Easy manipulation of hardware
  • High level Relying on lower level software to
    implement task with minimum amount of code.
  • Strengths
  • Not restrictive, especially in relation to type
    conversion.
  • More efficient than C and Java.
  • Weaknesses
  • Not object-oriented does not support abstraction
    and encapsulation
  • Difficult to manage in large projects.
  • Little built-in functionalities. Programmer need
    to start from scratch.
  • Easy to make mistakes. (pointers, ab vs ab)

4
C, C, and Java
  • C designed in 1980s, complete superset of C
  • Changes
  • Support for Object-Oriented programming
  • Strengths
  • Improved data abstraction and encapsulation
  • Makes it easier to manage large projects
  • More extensive built-ins (standard libraries)
  • Weakness
  • Considered by many to be over-complicated
  • Contains all of Cs problems

5
C, C, and Java
  • C designed in 1980s, complete superset of C
  • Changes
  • Support for Object-Oriented programming
  • Strengths
  • Improved data abstraction and encapsulation
  • Makes it easier to manage large projects
  • More extensive built-ins (standard libraries)
  • Weakness
  • Considered by many to be over-complicated
  • Contains all of Cs problems

6
A Short History of Java
  • 1991, Green Project, A group of engineers from
    Sun, led by Patrick Naughton, Sun Fellow, James,
    Gosling wanted to design a small consumer devices
    computer language, which has to be small, tight,
    platform-neutral, secure. So burn Java.
  • 1992, 7 intelligent remote control (no
    buyer).
  • 1993-1994 Green project tried to sell the
    technology, but no buyer.
  • Mean while WWW was growing. In 1994 most people
    were using Mosaic create by Marc Andreessen.
  • In 1994, created HotJava with Java.
  • 1995, demo HotJava at Sun World inspired the Java
    crazy
  • 1996 Sun released Java 1.0, but it is not for
    serious application.
  • 1998, released Java1.2 Standard SDK with a solid
    graphic toolkits.
  • Version 1.3, 1.4 are incremental improvements
    over the initial release.
  • 2004, released version 5.0 that updated the Java
    language in significant way.

7
C, C and Java
  • Java a language of 1990s
  • The design of Java starts with C syntax and
    semantics
  • Adds a few features from C Objects, exceptions
  • Leaves out parts unneeded, unsafe, complex (not
    backward compatible)
  • Gosling Java omits many rarely used, poorly
    understood, confusing features of C that in our
    experience bring more grief than benefits.
  • Adds a few facilities not present in C or C
  • Garbage collection, concurrency, runtime error
    checking, object serialization, interface, inner
    classes, threads
  • Strengthens portability and security

8
C, C and Java
9
Outline
  • C, C, and Java
  • How Java is related to C and C
  • Advantages of Java
  • Writing good codes in Java is easier than in C or
    C
  • Java libraries (packages)
  • Where the power of Java come from
  • Java and the internet
  • What Java is good for
  • Course content

10
Advantages of Java
  • According to Suns Java White paper
  • Java is a simple, objected-oriented,
    distributed, interpreted, robust, secure,
    architecture-neutral, portable, high-performance,
    multi-threaded, and dynamic language.
  • Most of the claims are justified, while others
    are controversial.

11
Advantages of Java/Simple
  • Streamlined C language
  • No typedef, union, goto, comma operator
  • No header files
  • C list.h, list.c
  • Java List.java
  • No makefile
  • Java compiler can figure out dependencies among
    classes

12
Advantages of Java/Simple
  • Fixed problematic areas
  • No pointers, no function pointers
  • Add garbage collection. Memory leaks no more
  • No code like this
  • if ( Head NULL )
  • Head(NODESET ) memAllocate(sizeof(NODESET))
  • (Head5) tmpNode
  • (Head)-gtnext(Head)-gtprevNULL
  • memDeallocate( Head )
  • Eliminated the possibility of confusing an
    assignment with a test for equality in a
    conditional statement.
  • if (ab) does not compile

13
Advantages of Java/Simple
  • Everything is a class except several primitive
    types
  • Array is a class. Cannot go over bound.
  • No this
  • int a5 a50
  • However, Java libraries are quite complicated

14
Advantages of Java/Object-Oriented
  • More so than C.
  • Combine data and behavior into one unit, the
    object
  • Programs are collections of interacting,
    cooperating objects
  • Advantages of OOP
  • Provide strong data abstraction and encapsulation
  • Gives framework for design
  • Allows independent development and testing
  • Facilitates system extensions and maintenance
  • More opportunity for code re-use

15
Advantages of Java/Platform-Independent
  • C and C programs are compiled into object code,
  • Object code is directly processed by hardware
    processor.
  • Require a separate compiler for each computer
    platform, i.e. for each computer operating system
    and the hardware set of instructions that it is
    built on.
  • Java programs are compiled into bytecode
  • Bytecode is processed by a program called java
    virtual machine (JVM), rather than by the "real"
    computer machine, the hardware processor.
  • Platform differences dealt with by JVM
  • Consequently, Java programs can run on any
    platform. Write once, run anywhere.

16
Java Virtual Machine
Runtime environment (Java Platform)
Compile time environment
Class loader bytecode to verifier
Java Libraries
Java Source
Java Virtual Machine
Bytecodes move locally or through net
HotSpot Compiler
Java Compiler
Runtime System
Operating System
Java bytecode (class)
Hardware
17
Advantages of Java/Distributed and Multithreaded
  • Networking capabilities of Java is both strong
    and easy to use.
  • It is easy to do multithreading in Java. Threads
    in Java can even take the advantage of
    multiprocessor system.

18
Advantages of Java/Robust and Secure
  • Fewer language loopholes
  • No pointers, typecasts limited. (Easier to
    produce error free source code)
  • Compilers are strict
  • Require initialization of variables, enforces
    type consistency, requires
  • prototypes (Less chance of error in compiled
    code)
  • Runtime error checking
  • Array bounds, null reference access (Less chance
    of runtime error)
  • Security manager
  • System to control permissions for high-level
    actions
  • Runtime verifier checks untrusted bytecode
  • Avoids havoc from hand-constructed bytecode

19
Advantages of Java
  • In Summary, writing good/bug-free codes in Java
    is easier than in C or C
  • javadoc generates documentation automatically
  • Very useful
  • Example HLCM

20
Outline
  • C, C, and Java
  • How Java is related to C and C
  • Advantages of Java
  • Writing good codes in Java is easier than in C or
    C
  • Java libraries (packages)
  • Where the power of Java come from
  • Java and the internet
  • What Java is good for
  • Course content

21
Java Libraries
  • Java has far expanded traditional scope of a
    languages libraries
  • Java 2 SDK 5.0
  • 3,270 classes and interfaces
  • 32,138 methods
  • Much less effort required to accomplish common
    tasks
  • Platform-specific details are handled
  • All programs improved when common core updated

22
Java Libraries
  • Collection of classes grouped into packages
  • Java equivalent of C libraries
  • java.lang
  • String, Math, Exception, Thread, Runtime, etc
  • java.util
  • Vector, Stack, hashtable, Date, Tokenizer
  • java.io
  • Varieties of input/output processing
  • java.net
  • Networking, client/server sockets, URLs
  • java.awt, javax.swing
  • Windows, buttons, drawing, images, events

23
Java Libraries
  • java.security
  • Encryption, digital signature, message digest
  • java.text
  • Formatting and parsing
  • java.sql
  • Database connectivity
  • java.rmi
  • Remote method invocation, distributed objects
  • The list goes on
  • And it is continuing to expand. Java is still
    young

24
Outline
  • C, C, and Java
  • How Java is related to C and C
  • Advantages of Java
  • Writing good codes in Java is easier than in C or
    C
  • Java libraries (packages)
  • Where the power of Java come from
  • Java and the internet
  • What Java is good for
  • Course content

25
Java and the Internet
  • Java is intended to be used in networked/distribut
    ed environments.
  • Increasingly used for middleware to communicate
    between clients and servers, acting as a
    universal glue that connect user with information
    from various sources. Example JMOL
  • Made possible by portability and multithreading
    and networking capabilities.

JDBC
26
Course Contents
  • Language Basics
  • Classes, objects, inheritance, interface, inner
    classes, exception, I/O stream
  • Components in the following diagram
  • Other issues
  • Multithreading, network, Applet, security

Applet
Client Browser
Server
Java Networking
Applet Swing (GUI)
Servlet
Remote Method Invocation
JDBC
DB
User
Write a Comment
User Comments (0)
About PowerShow.com