java -an overview

Upload: prathik-nagaraj

Post on 08-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 JAVA -an overview

    1/25

    Java - An Introduction

    Java - The new programming language fromSun Microsystems

    Java -Allows anyone to publish a web pagewith Java code in it

    Java - CPU Independent language

    Java - James , Arthur Van , and others

    Java -The name that survived a patent

    search Oak -The predecessor of Java

    Java is C++ -- ++

  • 8/7/2019 JAVA -an overview

    2/25

    Java as Object Oriented

    Objects all the way down

    Simple and Familiar: C++ Lite

    No Pointers! Dynamic Binding

    Single Inheritance with Interfaces

  • 8/7/2019 JAVA -an overview

    3/25

    According to Sun, Java is...

    Simple and PowerfulSimple and Powerful Object OrientedObject Oriented

    PortablePortable

    Architecture NeutralArchitecture Neutral

    DistributedDistributed

    MultiMulti--threadedthreaded

    Robust, Secure/SafeRobust, Secure/Safe

    InterpretedInterpreted

    High PerformanceHigh Performance

    DynamicDynamic pogrammingpogramming language/platform.language/platform.

  • 8/7/2019 JAVA -an overview

    4/25

    Total Platform Independence

    JAVA COMPILERJAVA COMPILER

    JAVA BYTE CODEJAVA BYTE CODE

    JAVA INTERPRETERJAVA INTERPRETER

    Windows 95 Macintosh Solaris Windows NT

    (translator)

    (same for all platforms)

    (one for each different system)

  • 8/7/2019 JAVA -an overview

    5/25

    Java Virtual Machine

    Must Run on Any Architecture

    Program

    in JavaJava

    Compiler

    Java

    Bytecode

    Java Virtual Machine

    WRITE ONCE, RUN ANYWHERE!

    debug

    pretty portable

  • 8/7/2019 JAVA -an overview

    6/25

    Why Java?

    Its the current hot language

    Its entirely object-oriented

    It has a vast library of predefined objectsand operations

    Its more platform independent

    this makes it great for Web programming Its more secure

    It isnt C++

  • 8/7/2019 JAVA -an overview

    7/25

    Java in the World ofDistributed Computing

    Class Loader

    Lightweight Binary Class Files

    Multithreading Dynamic

    Good communication constructs

    Secure

  • 8/7/2019 JAVA -an overview

    8/25

    Object Oriented Languages-a Comparison

    Feature C++Objective

    C Ada Java

    Encapsulation Yes Yes Yes Yes

    Inheritance Yes Yes No YesMultiple Inherit. Yes Yes No No

    Polymorphism Yes Yes Yes Yes

    Binding (Early/Late) Both Both Early Late

    Concurrency Poor Poor Difficult YesGarbage Collection No Yes No Yes

    Genericity Yes No Yes No

    Class Libraries Yes Yes Limited Yes

  • 8/7/2019 JAVA -an overview

    9/25

    Java better than C++ ?

    No Typedefs, Defines, or Preprocessor

    No Global Variables

    No Goto statements No Pointers

    No Unsafe Structures

    No Multiple Inheritance No Operator Overloading

  • 8/7/2019 JAVA -an overview

    10/25

    So Whats Java Good For?

    Java Applet

    Server

    Java Applet

  • 8/7/2019 JAVA -an overview

    11/25

    11

    The Java programming

    environment Java programming language specification Syntax of Java programs

    Defines different constructs and their semantics

    Java byte code: Intermediate representation for Java programs

    Java compiler: Transform Java programs into Java byte code

    Java interpreter: Read programs written in Java byte code and execute

    them

    Java virtual machine: Runtime system that provides various services

    to running programs

    Java programming environment: Set of libraries that provide services

    such as GUI, data structures,etc.

    Java enabled browsers: Browsers that include a JVM + ability to load

    programs from remote hosts

  • 8/7/2019 JAVA -an overview

    12/25

    Applets, Servlets and

    Applications An appletis designed to be embedded in a

    Web page, and run by a browser

    Applets run in a sandboxwith numerousrestrictions; for example, they cant readfiles and then use the network

    A servletis designed to be run by a webserver

    An application is a conventional program

  • 8/7/2019 JAVA -an overview

    13/25

    Java on the Web: Java Applets

    Clients download applets via Web browser Browser runs applet in a Java Virtual

    Machine (JVM)

    Interactive web, security, and client consistency

    Slow to download, inconsistent VMs (besides,

    flash won this war)

    Applet

    ClientServer

  • 8/7/2019 JAVA -an overview

    14/25

    Java on the Web: J2EE

    Thin clients (minimize download) Java all server side

    ClientServer

    JSPs

    Servlets

    EJB

    JDBC

  • 8/7/2019 JAVA -an overview

    15/25

    Applets and GUI

  • 8/7/2019 JAVA -an overview

    16/25

    AWT & Applets

    An Applet is a Java program capable of running from within a web page(HTML document)

    Steps to incorporate and run an applet:

    Have MyApplet.java

    javac MyApplet.java

    Have MyApplet.class Create MyApplet.html

    appletviewer MyApplet.html (or open MyApplet.html in browsers like

    Netscape/IE).

  • 8/7/2019 JAVA -an overview

    17/25

    Applet methods

    Unlike Applications, Applets do not have

    main().

    Instead, they have : init(), start(), stop(),

    paint(), update(), repaint(), destroy().

    All methods need not be implemented -- there

    are default versions for all of them.

    AppletContext Applet derived from AWT Panel

    Hooks into Browser environment

    Can be used to link to another Web page

  • 8/7/2019 JAVA -an overview

    18/25

    Multithreading in Java(A built-in feature in Java)

  • 8/7/2019 JAVA -an overview

    19/25

    Single and MultithreadedProcesses

    Single-threaded Process

    Single instruction stream Multiple instruction stream

    Multiplethreaded Process

    Threads of

    Execution

    Common

    Address Space

    threads are light-weight processes within a process

  • 8/7/2019 JAVA -an overview

    20/25

    Thread states

    new

    runnable non-runnable

    dead

    wait()

    sleep()

    suspend()

    blocked

    notify()slept

    resume()

    unblocked

    start()

    stop()

  • 8/7/2019 JAVA -an overview

    21/25

    Threading Mechanisms...

    Create a class that extends the Thread class

    Create a class that implements the Runnable interface

  • 8/7/2019 JAVA -an overview

    22/25

    Server

    Threads

    Message Passing

    Facility

    Server Process

    Client Process

    Client Process

    User Mode

    Kernel Mode

    Threads in Action...

    Multithreaded Server

  • 8/7/2019 JAVA -an overview

    23/25

    Just to Summarize

    Java as a Comprehensive Programming

    Solution

    Object Oriented Portable

    High Performance

    Geared for Distributed Environments

    Secure

    Highly suitable for Internet programming

  • 8/7/2019 JAVA -an overview

    24/25

    Java is really very well poised

    Incredible leverage from the Web

    Will impact the C++ and Smalltalk markets Rate of progress is astonishingly high

    Development environments

    CORBA linkages Components

  • 8/7/2019 JAVA -an overview

    25/25