CSE 452 Programming Languages Java and its Evolution

  • Slides: 39
Download presentation
CSE 452: Programming Languages Java and its Evolution

CSE 452: Programming Languages Java and its Evolution

Acknowledgements u Rajkumar Buyya Organization of Programming Languages-Cheng (Fall 2004) 2

Acknowledgements u Rajkumar Buyya Organization of Programming Languages-Cheng (Fall 2004) 2

Contents u Java Introduction u Java Features u How Java Differs from other OO

Contents u Java Introduction u Java Features u How Java Differs from other OO languages u Java and the World Wide Web u Java Environment u Build your first Java Program u Summary and Reference Organization of Programming Languages-Cheng (Fall 2004) 3

Java - An Introduction u Java - The new programming language developed by Sun

Java - An Introduction u Java - The new programming language developed by Sun Microsystems in 1991. u Originally called Oak by James Gosling, one of the inventors of the Java Language. u Java -The name that survived a patent search u Java Authors: Gosling, Arthur Van , and others u Java is really “C++ -- ++ “ Organization of Programming Languages-Cheng (Fall 2004) 4

Java Introduction u Originally created for consumer electronics (TV, VCR, Freeze, Washing Machine, Mobile

Java Introduction u Originally created for consumer electronics (TV, VCR, Freeze, Washing Machine, Mobile Phone). u Java - CPU Independent language u Internet and Web was just emerging, so Sun turned it into a language of Internet Programming. u It allows you to publish a webpage with Java code in it. Organization of Programming Languages-Cheng (Fall 2004) 5

Java Milestones Year Development 1990 Sun decided to developed special software that could be

Java Milestones Year Development 1990 Sun decided to developed special software that could be used for electronic devices. A project called Green Project created and headed by James Gosling. 1991 Explored possibility of using C++, with some updates announced a new language named “Oak” 1992 The team demonstrated the application of their new language to control a list of home appliances using a hand held device. 1993 The World Wide Web appeared on the Internet and transformed the text-based interface to a graphical rich environment. The team developed Web applets (time programs) that could run on all types of computers connected to the Internet. Organization of Programming Languages-Cheng (Fall 2004) 6

Java Milestones Year Development 1994 The team developed a new Web browsed called “Hot

Java Milestones Year Development 1994 The team developed a new Web browsed called “Hot Java” to locate and run Applets. Hot. Java gained instance success. 1995 Oak was renamed to Java, as it did not survive “legal” registration. Many companies such as Netscape and Microsoft announced their support for Java 1996 Java established itself it self as both 1. “the language for Internet programming” 2. a general purpose OO language. 1997 - A class libraries, Community effort and standardization, Enterprise Java, Clustering, etc. . Organization of Programming Languages-Cheng (Fall 2004) 7

Sun white paper defines Java as: u Simple and Powerful u Safe u Object

Sun white paper defines Java as: u Simple and Powerful u Safe u Object Oriented u Robust u Architecture Neutral and Portable u Interpreted and High Performance u Threaded u Dynamic Organization of Programming Languages-Cheng (Fall 2004) 8

Java Attributes u Familiar, Simple, Small u Compiled and Interpreted u Platform-Independent and Portable

Java Attributes u Familiar, Simple, Small u Compiled and Interpreted u Platform-Independent and Portable u Object-Oriented u Robust and Secure u Distributed u Multithreaded and Interactive u High Performance u Dynamic and Extensible Organization of Programming Languages-Cheng (Fall 2004) 9

Java is Compiled and Interpreted Hardware and Operating System Programmer Source Code Text Editor

Java is Compiled and Interpreted Hardware and Operating System Programmer Source Code Text Editor Byte Code Compiler . java file Notepad, emacs, vi Interpreter. class file javac Organization of Programming Languages-Cheng (Fall 2004) java appletviewer netscape 10

Compiled Languages Programmer Source Code Text Editor Compiler. c file Notepad, emacs, vi Object

Compiled Languages Programmer Source Code Text Editor Compiler. c file Notepad, emacs, vi Object Code. o file Executable Code linker a. out file gcc Organization of Programming Languages-Cheng (Fall 2004) 11

Total Platform Independence JAVA COMPILER (translator) JAVA BYTE CODE (same for all platforms) JAVA

Total Platform Independence JAVA COMPILER (translator) JAVA BYTE CODE (same for all platforms) JAVA INTERPRETER (one for each different system) Windows 95 Macintosh Solaris Organization of Programming Languages-Cheng (Fall 2004) Windows NT 12

Architecture Neutral & Portable u Java Compiler - Java source code (file with extension.

Architecture Neutral & Portable u Java Compiler - Java source code (file with extension. java) to bytecode (file with extension. class) u Bytecode - an intermediate form, closer to machine representation u. A interpreter (virtual machine) on any target platform interprets the bytecode. Organization of Programming Languages-Cheng (Fall 2004) 13

Architecture Neutral & Portable u Porting the java system to any new platform involves

Architecture Neutral & Portable u Porting the java system to any new platform involves writing an interpreter. u The interpreter will figure out what the equivalent machine dependent code to run Organization of Programming Languages-Cheng (Fall 2004) 14

Rich Class Environment u Core Classes language Utilities Input/Output Low-Level Networking Abstract Graphical User

Rich Class Environment u Core Classes language Utilities Input/Output Low-Level Networking Abstract Graphical User Interface u Internet Classes TCP/IP Networking WWW and HTML Distributed Programs Organization of Programming Languages-Cheng (Fall 2004) 15

How Does Java Compares to C++ and Other OO Languages Organization of Programming Languages-Cheng

How Does Java Compares to C++ and Other OO Languages Organization of Programming Languages-Cheng (Fall 2004) 16

Overlap of C, C++, and Java C++ C Java Organization of Programming Languages-Cheng (Fall

Overlap of C, C++, and Java C++ C Java Organization of Programming Languages-Cheng (Fall 2004) 17

Java better than C++ ? u No Typedefs, Defines, or Preprocessor u No Global

Java better than C++ ? u No Typedefs, Defines, or Preprocessor u No Global Variables u No Goto statements u No Pointers u No Unsafe Structures u No Multiple Inheritance u No Operator Overloading u No Automatic Coercions u No Fragile Data Types ? Organization of Programming Languages-Cheng (Fall 2004) 18

Object Oriented Languages -A Comparison Organization of Programming Languages-Cheng (Fall 2004) 19

Object Oriented Languages -A Comparison Organization of Programming Languages-Cheng (Fall 2004) 19

Java Integrates Power of Compiled Languages and Flexibility of Interpreted Languages Organization of Programming

Java Integrates Power of Compiled Languages and Flexibility of Interpreted Languages Organization of Programming Languages-Cheng (Fall 2004) 20

Java Applications u We can develop two types of Java programs: l Stand-alone applications

Java Applications u We can develop two types of Java programs: l Stand-alone applications l Web applications (applets) Organization of Programming Languages-Cheng (Fall 2004) 21

Applications v/s Applets u Different ways to run a Java executable are: Application- A

Applications v/s Applets u Different ways to run a Java executable are: Application- A stand-alone program that can be invoked from command line. A program that has a “main” main method Applet- A program embedded in a web page , to be run when the page is browsed. A program that contains no “main” method Organization of Programming Languages-Cheng (Fall 2004) 22

Applets v/s Applications u Different ways to run a Java executable are Application- A

Applets v/s Applications u Different ways to run a Java executable are Application- A stand-alone program that can be invoked from command line. A program that has a “main” main method Applet- A program embedded in a web page , to be run when the page is browsed. A program that contains no “main” method u Application –Executed by the Java interpreter. u Applet- Java enabled web browser. Organization of Programming Languages-Cheng (Fall 2004) 23

Java and World Wide Web Turning the Web into an Interactive and Application Delivery

Java and World Wide Web Turning the Web into an Interactive and Application Delivery Platform Organization of Programming Languages-Cheng (Fall 2004) 24

What is World Wide Web ? u Web is an open-ended information retrieval system

What is World Wide Web ? u Web is an open-ended information retrieval system designed to be used in the Internet wide distributed system. u It contains Web pages (created using HTML) that provide both information and controls. u Unlike a menu driven system--where we are guided through a particular direction using a decision tree, the web system is open ended and we can navigate to a new document in any direction. Organization of Programming Languages-Cheng (Fall 2004) 25

Significance of downloading Applets u Interactive WWW u Flashy animation instead of static web

Significance of downloading Applets u Interactive WWW u Flashy animation instead of static web pages u Applets react to users input and dynamically change u Display of dynamic data u WWW with Java - more than a document publishing medium u http: //www. javasoft. com/applets/alpha/applets/Sto ck. Demo/standalone. html Organization of Programming Languages-Cheng (Fall 2004) 29

Power of Java and the Web u Deliver applications, not just information u Eliminate

Power of Java and the Web u Deliver applications, not just information u Eliminate porting u Eliminate end-user installation u Slash software distribution costs u Reach millions of customers - instantly Organization of Programming Languages-Cheng (Fall 2004) 30

Java Development Kit u javac - The Java Compiler u java - The Java

Java Development Kit u javac - The Java Compiler u java - The Java Interpreter u jdb- The Java Debugger u appletviewer -Tool to run the applets u javap - to print the Java bytecode u javaprof - Java profiler u javadoc - documentation generator u javah - creates C header files Organization of Programming Languages-Cheng (Fall 2004) 31

Java Environment Organization of Programming Languages-Cheng (Fall 2004) 32

Java Environment Organization of Programming Languages-Cheng (Fall 2004) 32

Java Development Kit u javac - The Java Compiler u java - The Java

Java Development Kit u javac - The Java Compiler u java - The Java Interpreter u jdb- The Java Debugger u appletviewer -Tool to run the applets u javap - to print the Java bytecodes u javaprof - Java profiler u javadoc - documentation generator u javah - creates C header files Organization of Programming Languages-Cheng (Fall 2004) 33

Process of Building and Running Java Programs Text Editor Java Source Code javadoc HTML

Process of Building and Running Java Programs Text Editor Java Source Code javadoc HTML Files Java Class File javah Header Files java jdb javac Outout Organization of Programming Languages-Cheng (Fall 2004) 34

Let us Try Out Building your first Java Program Organization of Programming Languages-Cheng (Fall

Let us Try Out Building your first Java Program Organization of Programming Languages-Cheng (Fall 2004) 35

Hello Internet // hello. java: Hello Internet program class Hello. Internet { public static

Hello Internet // hello. java: Hello Internet program class Hello. Internet { public static void main(String args[]) { System. out. println(“Hello Internet”); } } Organization of Programming Languages-Cheng (Fall 2004) 36

Program Processing u Compilation # javac hello. java results in Hello. Internet. class u

Program Processing u Compilation # javac hello. java results in Hello. Internet. class u Execution # java Hello. Internet Hello Internet # Organization of Programming Languages-Cheng (Fall 2004) 37

Simple Java Applet //Hello. World. java import java. applet. Applet; import java. awt. *;

Simple Java Applet //Hello. World. java import java. applet. Applet; import java. awt. *; public class Hello. World extends Applet { public void paint(Graphics g) { g. draw. String (“Hello World !”, 25); } } Organization of Programming Languages-Cheng (Fall 2004) 38

Calling an Applet <HTML> <TITLE>HELLO WORLD APPLET</TITLE> <HEAD>THE HELLO WORLD APPLET</HEAD> <APPLET CODE=“Hello. World.

Calling an Applet <HTML> <TITLE>HELLO WORLD APPLET</TITLE> <HEAD>THE HELLO WORLD APPLET</HEAD> <APPLET CODE=“Hello. World. class” width=500 height=500> </APPLET> </HTML> Organization of Programming Languages-Cheng (Fall 2004) 39

Applet Execution Using Applet. Viewer Organization of Programming Languages-Cheng (Fall 2004) Using Browser 40

Applet Execution Using Applet. Viewer Organization of Programming Languages-Cheng (Fall 2004) Using Browser 40

Java on my platform ? u u u u u Sun (SPARC) ftp: //java.

Java on my platform ? u u u u u Sun (SPARC) ftp: //java. sun. com Sun(x 86) ftp: //xm. com: /pub/ IBM(Aix, OS/2)ftp: //ncc. hursley. ibm. com/javainfo DEC(Alpha OSF/1) http: //www. gr. osf. org: 8001/projects/web/java/ SGI http: //liawww. epfl. ch/~simon/java/irix-jdk. html HP http: //www. gr. osf. org: 8001/projects/web/java linux http: //www. blackdown. org AT & T http: //www. gr. osf. org: 8001/projects/web/java Windows 3. 1 http: //www. alphaworks. ibm. com Organization of Programming Languages-Cheng (Fall 2004) 41

Summary u Java has emerged as a general purpose OO language. u It supports

Summary u Java has emerged as a general purpose OO language. u It supports both stand alone and Internet Applications. u Makes the Web Interactive and medium for application delivery. u Provides an excellent set of Tools for Application Development. u Java is ubiquitous! Organization of Programming Languages-Cheng (Fall 2004) 42