290 likes | 507 Views
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”. Agenda. Java Virtual Machine Java App/Servlet & JavaScript Java Language.
E N D
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”
Agenda • Java Virtual Machine • Java App/Servlet & JavaScript • Java Language
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 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
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????
JIT Compilation • “Just-in-time” compilation: • Convert Java bytecodes to native code as they are executed • Total execution time = compilation time + run time