26
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999

got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999

  • View
    217

  • Download
    0

Embed Size (px)

Citation preview

got ?

Research Project – April 1998

Hang Xia, Mark Wang, Richard S. Chang

Updated: R Norman, August 1999

Why is Java so Hot?

– because of the NETWORK!!

Why Java?

– “Write Once, Use Anywhere”

• Java Virtual Machine

• Java App/Servlet & JavaScript

• Java Language

Agenda

Java

Virtual

Machine

Java Virtual Machine

What is the JVM?– A Java Interpreter

– Software, not hardware– Converts bytecode into machine code

Why JVM is important?– Platform-Independent

Java Development andJava Runtime Environment (JRE)

Java Development Kit (JDK) A development environment for writing

– Java Applets & Servlets– Java Applications

JDK contains– Java Core Classes– Java Source Files– Java Tools (compiler, Interpreter,

appletviewer, debugger, etc.)– Java Documentation and Demos

Java Applet

Java Servlet

JavaScript

What is a Java Applet?

A Java program that can be included in an HTML page.

An applet tag is used in the HTML file to identify the source of the applet code, which resides on the server.

Example applet tag in HTML file:

<applet code=“MyApplet.class” width=100 height=80></applet>

How a Java Applet works

When we use a Java-compatible browser to view a Web page which contains a Java applet, the applet’s code is transferred to our system and executed by the browser.

Java-Compatible Browsers: HotJava, Netscape Navigator, Internet Explorer, etc.

Why a Java Applet?

ADVANTAGES:

Less load on the server

More user interaction (Applet Vs. CGI)

Arbitrary graphics

Arbitrary data types

Java Applets Vs. Java Applications

Java Application:

Standalone Java programs that can be run by using just the Java interpreter.

Java Applet:

Run and displayed inside a Web page with

Java-enabled Web browser.

Embedding Applet in HTML <APPLET CODEBASE = codebaseURL

ARCHIVE = archiveList

CODE = appletFile ...or... OBJECT = serializedApplet ALT = alternateText

NAME = appletInstanceName

WIDTH = pixels HEIGHT = pixels ALIGN = alignment

VSPACE = pixels HSPACE = pixels > <PARAM NAME = appletAttribute1 VALUE = value>

<PARAM NAME = appletAttribute2 VALUE = value>

. . .

alternateHTML

</APPLET> ( Applet Tag )

What is JavaScript?

JavaScript is a cross-platform, object-based scripting language for client and server applications.

Untyped language Purely interpreted language

Is JavaScript Simplified Java?

NO

JavaScript Vs. Java

JavaScript -- Interpreted (not compiled) by client. Code integrated with and embedded in HTML.

Java -- Compiled bytecodes downloaded from server, executed on client. Applets distinct from HTML (accessed from HTML pages).

Embedding JavaScript in HTML

Explicit Way <SCRIPT>

JavaScript statements …

</SCRIPT>

Implicit Way <SCRIPT SRC=“common.js”>

</SCRIPT>

Java

Language

Java Language

Syntactically similar to C++ Semantically different

– Strong and statically typed

– Single inheritance plus an interface mechanism

– Run-time type information

Automatic storage management:– No pointers

– Garbage collection

Security/safety

Advantages of Java

Combine many programming mechanisms– Object oriented language

– Strongly and statically typed

– Automatic storage management: garbage collection

– Run-time type information

– Safety

Faster build cycle (prototyping)– Dynamic linking

Advantages of Java (cont.)

Platform independence– The ability of write code once and use it anywhere

– The ultimate in portability

– Compiled code can move around a network

Java is “Open”– Documentation and source code available

– Not tied down to a single vendor (i.e. Sun or Microsoft)

Disadvantages of Java

Implementations have traditionally been interpreted– Execute slower than compiled languages

– Typically in the order of 10x slower than native code

“Write Once, Run Anywhere” Implementation challenges

Is Microsoft playing????

Build Cycle

T r a d i t i o n a l l y : c o m p i l e s o u r c e c o d e t o p l a t f o r m d e p e n d e n t o b j e c t c o d e l i n k o b j e c t t o f o r m a n e x e c u t a b l e i m a g e l o a d t h e i m a g e a n d b e g i n e x e c u t i n g

Source Code Object Code Excutable Image

Compile Link

Build Cycle (cont.)

T h e J a v a m o d e l : C o m p i l e s o u r c e t o p l a t f o r m i n d e p e n d e n t “ b y t e c o d e s ” E x e c u t e b y s p e c i f y i n g a c l a s s t o s t a r t r u n n i n g N e w c l a s s e s a r e l o a d e d a s r e q u i r e d

Source Code Class file

Compile Executed byJVM

JIT Compilation

“Just-in-time” compilation:– Convert Java bytecodes to native code as they

are executed

Total execution time = compilation time + run time

Questi ns ?