Given by NPAC Team at SC95 Tutorial on Web Technologies on December 4,95. Foils prepared January 8,96
Abstract * Foil Index for this file
Overview including History and the great alpha versus beta Java Mystery |
HotJava Features |
Java Features |
Java Programming Language |
Abstract Windowing Toolkit |
On-Line HTML Documentation |
Security Model |
Applets Programming |
NPAC Java Demos
|
This table of Contents
Abstract
Supercomputing 95 |
Monday December 4,1995 |
San Diego Convention Center |
NPAC |
Geoffrey Fox, Wojtek Furmanski, Marek Podgorny with |
Gang Cheng, Roman Markowski |
Syracuse University |
111 College Place |
Syracuse |
NY 13244-4100 |
Overview including History and the great alpha versus beta Java Mystery |
HotJava Features |
Java Features |
Java Programming Language |
Abstract Windowing Toolkit |
On-Line HTML Documentation |
Security Model |
Applets Programming |
NPAC Java Demos
|
HotJava is a Web browser that supports dynamically downloadable interactive content. |
Arbitrarily sophisticated dynamic multimedia applications inserts called Applets can be embedded in the regular HTML pages and activated on each exposure of a given page. |
Applet constructs are implemented in terms of a
|
Applets are written in Java -- a new general purpose object-oriented programming language from Sun Microsystems. |
Starts in 1991 by Project Green --- a group in Sun that detaches from the main campus as a semi-autonomous task force focused on operating software for consumer electronic devices such as smart set-top boxes |
Gosling (creator of Sun NeWS which had major conceptual impact both on current Java and Telescript models) realizes that C++ is not adequate and initiates development of a new language Oak, later renamed as Java. |
A PDA (codename *7) based on Oak/Java ready in 1993. Green Team incorporates as FirstPerson, Inc. |
*7 proposal to Time-Warner rejected in 1993. 3DO deal falls through in 1994. FirstPerson, Inc. dissolves. |
Small group (~30 people, now Java Team) continues development and decides to adapt Oak as a Web technology. |
An experimental web browser written in Java, called WebRunner and later renamed as HotJava, ready in 1994. |
Java/HotJava published in April '95. |
Netscape licences Java in May '95 -- this triggers a series of other licensing agreements with major vendors and results in the current slowdown in the public releases of Java/Hotjava. |
Beta JDK (Java Development Kit) published in summer/fall '95. It is better software but lower functionality than Alpha. |
First Java books appear in fall '95 such as a popular overview by SAMS and technical book "Java!" by Tim Ritchey, edited by New Riders. |
Dec 4 1995 Business Week cover story on "Software Revolution --- The Web Changes Everything" exposes Java as a breakthrough force in the expanding Web/Internet. Also points out that "Java as a business" is yet to be defined. |
When you start exploring Java world today, you need to make an upfront decision as to where to start as there are two options: Alpha or Beta, and "obviously Beta" is not so obvious --- it depends on why and how do you want to use Java in the near term. |
In fact, this talk, although largely Alpha-Beta independent, uses examples from the Alpha version (and so does Ritchey's book). Here is why. |
Alpha release of Java/Hotjava included:
|
In Short, Alpha Java/HotJava was a complete software release of all system components, free for research and subject to ($125K) licence for business use. |
Beta JDK appeared after a series licensing successes and it claims to be compatible with ongoing Java implementations by all licensees, most notably Netscape. Beta JDK includes:
|
The choice between Alpha and Beta depends on why and how do you want to use Java.
|
Warning: if you are using Alpha, don't do any serious development as you will be likely out of the mainstream soon unless you also watch Beta and monitor differences. |
Announcements of December 1995 clarify the medium term future but don't solve near term problems |
JAVA will be "open" Web standard |
Sun promises browser classes (beta Hot Java) soon -- then we can all compete with Netscape |
Netscape renames Livescript as Javascript and this is an interesting subset of Java which is fully interpreted -- use for overall customization of client |
Hooked on Java by Java developers Arthur van Hoff, Sami Shaio, Orca Starbuck is (first) serious (but still rather high-level) book on beta Java
|
JavaScript: Interpreted by client and NOT compiled |
Java: Compiled on Server before execution on client
|
JavaScript: Object based -- no classes or inheritance -- built in extensible objects |
Java: Object-oriented. Programs consist of object classes with inheritance |
JavaScript: Integrated with HTML as embedded ascii but of course HTML looks rather irrelevant at times! |
Java: Applets distinct from HTML but invoked from HTML Pages |
JavaScript: do not declare variables' datatypes -- Loose typing |
Java: MUST declare variables' datatypes -- Strong typing |
JavaScript -- Dynamic Binding -- object references computed at runtime |
Java -- Static Binding -- object references must exist at compile time |
Java and JavaScript are secure and cannot write to disk |
Document The Hot Java: A White Paper by Sun Microsystems enumerates the following main features of HotJava: |
Modular Browser Design |
Interactive Content |
Dynamic Types |
Dynamic Protocols |
Open and Closed Model |
HotJava is written in Java in a highly modular fashion |
Java source code used to build HotJava is collected in an integrated package called 'browser', containing ~50 classes. The browser itself is also a Java class, called 'hotjava'. |
Individual protocols and content handlers ("viewers") are packaged as Java classes, managed by HotJava. New protocols and/or handlers can be dynamically downloaded and automatically installed when needed. |
In consequence, HotJava can be easily and dynamically customized to the needs of individual users and/or applets. |
Applets can implement arbitrary interaction dynamics based on mouse/keyboard input and multimedia (graphics, sound) output. |
Typically, an applet will download a little simulation, mouse tracking or drawing/painting software and the interaction with the user will be handled by the Java interpreter, running at the client side. The performance and response time is therefore much higher than in client-server interaction models. |
Technical implementation of HotJava GUI is achieved in terms of the Abstract Windowing Toolkit which offers common, platform-independent abstraction of a generic window server (which is implemented in terms of X/UNIX, Windows/PC and Macintosh models on the individual platforms) |
At the moment, (alpha) Java is supported on Sun Solaris and WindowsNT platforms. Other ports are in progress. |
New data types (for example new video compression formats etc.) can be supported in Java even if HotJava browsers are not aware of such new formats. |
The data processing software needs to be packaged in terms of Java classes and provided together with the data access itself. |
HotJava downloads and dynamically installs the processing software first, and then proceeds with handling the data. |
In a similar way, the model can handle a variety of custom communication protocols, e.g. proprietary extensions of HTTP including some special security issues. The protocol handler needs to be provided as a Java package together with the protocol. It will be dynamically installed by HotJava and then used to handle the message transfer. |
HotJava offers a promising solution to the major software engineering problem -- retain the system open for innovation while it is at the same time closed i.e. ready for shipment and production use. |
This compromise is achieved by building HotJava in terms of a collection of cooperating but largely autonomous classes/modules. |
HotJava as of today represents one particular implementation of a Java based Web browser concept, and it leaves freedom to innovate and customize. |
Dedicated browsers for scientific research or K-12 education needs can easily be tailored in terms of reusable building blocks of the Java 'browser' package. |
This is in contrast with monolithic browsers such as Netscape which will become increasingly difficult to maintain and adapt to rapidly varying Internet trends. |
Document The Java: A White Paper by Sun Microsystems enumerates the following main features of Java: |
Simple |
Object-oriented |
Distributed |
Interpreted |
Robust |
Secure |
Architecture-neutral |
Portable |
High performance |
Dynamic |
Java omits several rarely used, poorly understood and confusing features of C++ including operator overloading, multiple inheritance and automatic pointer coercions. |
It adds automatic garbage collection which makes dynamic programming easier in Java than in C++. |
It also adds 'Interface' construct, similar to Objective C concept, which often compensates for the lack of multiple inheritance. |
The resulting language retains the essence of C++ but is simpler and hence easier to program in. |
It also results in a much smaller kernel which is suitable for planned Java ports to consumer electronic devices. Base interpreter is ~40Kb, libraries and threads add additional 175Kb. |
Java model can be viewed as a C++ subset, with some dynamic elements inherited from Objective-C (method overloading, garbage collection). |
The strength of Java object-oriented model is not is sophistication but in simplicity and the extensive class library associated with the system (~250 public classes). |
Java class plays also a role of a communication atom in the Web embedding model. Applet classes identify themselves by names in the HTML applet tag. Applet downloads other classes, present in the applet source. Hence, the Java class names play the role of addressing mode for the distributed Java code database. |
Popular TCP/IP based protocols such as FTP or HTTP are supported in terms of network protocol classes. This facilitates various forms of distributed processing. New protocols (e.g. PVM etc.) can added and dynamically installed. |
Distributed computing model of Java is mainly client-server, with Java compiler preparing the opcodes at the server side, and Java interpreter executing it at the client side. |
Some more dynamic forms of Java/HotJava distributed processing are being explored recently by "early adopters". For example, a distributed Pong game in which two HotJavas bounce the ball off the common Web server, or Java+MBONE based World-Wide collaboratory environment. |
Java enforces compiler-time type checking and eliminates this way some error prone constructs of C/C++. |
Pointer arithmetic is fully eliminated which allows e.g. for runtime checking of array subscripts and enforces security of the Java model. |
Explicit declarations are always required, i.e. C-style implicit declarations are abandoned. This allows the Java complier for early error detection. |
Rapid prototyping in Java is less natural than in Lisp, Tcl, Smalltalk or Perl, but the software quality assurance of Java is higher than in these more dynamic and 'forgiving' languages. |
Java binaries are shipped across the network and executed on client machines. Security is therefore a critical issue and strongly enforced in Java. |
Modifications of the C++ model such as eliminating pointer arithmetic and coercion were dictated mainly by the security requirements. |
Most viruses are based on acquiring access to private/protected sectors of computer memory which is impossible in Java. |
Java opcodes are executed at the client side by Java interpreter which operates exclusively on the virtual memory. Hence, unless there are security bugs in the Java interpreter itself, the model is safe and users cannot create security holes by incorrectly or maliciously written applets. |
C/C++ programming in a heterogeneous network environment requires use and compatibility across several vendor platforms and the corresponding compilers. This problem is solved in Java by designing platform-independent binary representation called Java bytecode (or opcode). |
Java compiler (written in Java and platform-independent) reads Java source and generates Java bytecode. These bytecodes are shipped to client machines upon browser requests. |
Each client machine must run Java interpreter which performs runtime execution of Java bytecodes. Java interpreter is written in POSIX compliant ANSI C and needs to be ported to and conventionally compiled (once) on each individual platform. |
Once the interpreter is ported, application developers don't need to worry at all about platform specificity and differences between native compilers. They write portable Java which is compiled by platform independent Java compiler and executed on Java interpreter, ported to various platforms. |
Java language offers a uniform abstract machine model which is identical for all platforms. |
Unlike in C/C++ where various integers match the architecture of a physical machine at hand, Java byte, short, int and long are always of the same size, equal to 8, 16, 32 and 64 bits, respectively. |
Differences between vendor specific windowing environments (X Windows, MS Windows, Macintosh) are removed in terms of the Abstract Windowing Toolkit (AWT) metaphor. |
AWT is given by ~60 Java classes which offer a universal GUI programming model, portable between UNIX, PC and Mac, and translated automatically to native windowing systems on individual platforms by Java interpreters. |
Java represents a compromise between fully compiled (like C/C++) and fully interpreted (like Smalltalk or Perl) models. |
Java "compiler" produces a binary bytecode output which is portable and much smaller than the real binary for a specific machine (Typical bytecode size is of order of the original source code, within a factor of 2). |
Java "interpreter" executes this bytecode and is therefore less dynamic than e.g. Perl interpreter (which performs an equivalent bytecode construction internally and on-the-fly when reading the program source). |
In general, the compilation process is: a) time consuming and b) platform specific. Hence, interpreters are built and used to facilitate a) rapid prototyping and/or b) portability. Java model is focused on platform independence but the development throughput is also reasonable since the Java compiler is fast and generates compact bytecode output. |
Java interpreter performs on-the-fly runtime execution of the Java bytecodes which results typically in a satisfactory performance. |
Support for generating native machine code out of Java bytecodes, viewed as intermediate compiler form, is also provided and useful for performance demanding applications. |
The performance of the machine code, generated from Java bytecodes, is comparable to that offered by typical C/C++ compilers on the same platform. |
Several of these concepts are in fact similar as in the OSF/ANDF project. Using ANDF terminology, we would call Java compiler a 'producer', and the machine code generator discussed here, an 'installer'. Default Java working mode doesn't use installers but directly interprets the intermediate form (this mode is supported in ANDF by GAI -- Generalized ANDF Interpreter). |
ANDF model is in principle applicable to all languages. Java/HotJava system implements ANDF concepts for the Java language. |
Java model offers preemptive multithreading, implemented in terms of the Thread class. Thread methods offer a set of synchronization primitives based on monitor and conditional variable paradigm by C.A.R. Hoare. Java threads inherit some features from the pioneering Cedar/Mesa System by Xerox Park that gave birth to Macintosh and object-oriented programming. |
A typical use of Java multithreading in applet programming is to have several independent but related simulations (e.g. various sorting algorithms), running concurrently in an applet window. Multithreading is also used internally by the HotJava browser to handle multiple document dynamics. |
Another interesting application domain are multi-HotJava environments to come such as collaboratory or gaming. |
Java threads don't have built-in point-to-point communication primitives. Various thread communication environments can be provided by coupling the thread and network protocol objects. |
Java model is more dynamic that C++ and closer to Smalltalk or Perl. |
Subclasses don't need to to be recompiled after superclass implementation is updated. |
Classes have runtime representation (implemented in terms of the Class class) which allows for reliable dynamic cast and type checking operations. |
A class hashtable is maintained by the runtime system and allows for programmatic symbolic interfaces to class symbol tables. |
Class mobility and caching is not yet supported but aspects of it are likely to be available in beta version of Java expected in fall '95. |
This module material is based on The Java Language Specification by Sun Microsystems, Inc., March 1995. |
Program Structure |
Lexical Issues |
Types |
Classes |
Interfaces |
Packages |
Expressions |
Statements |
Floating Point |
Source code of a Java program consists of one or more compilation units, implemented as files with .java extension. |
Each compilation unit can contain:
|
Java compiler (called javac) reads java source and produces a set of binary bytecode files with .class extensions, one for each class declared in the source file. For example, if foo.java implements Foo and Fred classes, then "javac foo.java" will generate Foo.class and Fred.class files. |
Suppose that Foo implements an applet and Fred is an auxiliary class used by Foo. If HotJava encounters a tag <APP "Foo">, it will download Foo.class and Fred.class files and it will start interpreting bytecodes in Foo.class. |
Lexical structure inherits a lot from C/C++. There are however some notable differences which are listed below. |
Java characters are based on 16--bit wide Unicode Worldwide Character Encoding rather than the usual 8--bit wide ASCII. |
Three types of comments are supported:
|
Java reserves the following keywords:
|
Each Java variable or expression has a definite type. Simple types such as integers or booleans are built-in. New composite types can be constructed in terms of classes, arrays and interfaces. |
There are 4 integer types: byte, short, int, long of size 8, 16, 32 and 64 bits, respectively. |
Float is 32 bits, double is 64 bits. Floating point arithmetic and data formats are defined by IEEE754. |
Characters are given by Unicode charset and represented as short integers. |
Arrays are "true" or "first class" objects in Java and no pointer arithmetic is supported. Hence, arrays are handled as all other composite objects and its special role is due only to some syntactic sugar inherited from C/C++. |
An Array is declared as:
|
and created by:
|
or concisely:
|
Subscripts are range checked in runtime and so vec[-1] and vec[128] will generate exceptions. |
Array length can be extracted via the length instance variable, e.g.
|
Arrays of arbitrary objects can be constructed,
|
Class declaration in Java shares common aspects with C++ but there are also some syntactic and semantic differences. |
Base syntax is simpler, cleaner and more intuitive. However, Java introduces some new modifiers, for example:
|
Only single inheritance is supported but aspects of multiple inheritance can be achieved in terms of the interface construct. Interface is similar to an abstract class with all methods being abstract and with all variables being static (global). Unlike classes, interfaces can be multiply-inherited. |
We illustrate essential elements of Java object-oriented programming on the following example. |
The following three classes are declared:
|
and they are all made Movable (i.e. they all implement Movable interface). |
Declaration of Interface Movable:
|
public class Point implements Movable |
{ float x, y; |
public Point(float x, float y) {
|
public Point() {
|
private float clip(float x) {
|
public void move(float dx, float dy) {
|
public void move() {
|
} // end class Point |
public class Rectangle implements Movable |
{ |
Point p; |
float w, h; |
public Rectangle(float x1, float y1, float x2, float y2) {
|
} // end class Rectangle |
import awt.Color; |
import awt.Graphics; |
public class Canvas extends Rectangle implements Movable |
{ Color fg, bg; |
public Canvas(float x1, float y1, float x2, float y2, Color fg, Color bg) {
|
public void inverse() {
|
public void paint(Graphics g) {
|
} // end class Canvas |
Java methods can be overloaded (i.e. allow for multi-valued declaration with various argument patterns -- see e.g. move() method) in a similar way as class constructors. |
Canvas inherits move() method, and overrides inverse() method (by adding color inversion, i.e. "inverse video"). |
paint() method operates on Graphics object from Sun's Java class library which is included via the import statement. |
We used the interface construct to separate 2D translational degrees of freedoms (which are handled as Movable methods) from the internal coordinates (which are handled by individual classes). |
Note that interfaces can only contain static (global) variables (here, x=0.0, y=0.0 which is the default origin for Point() constructor).
|
Classes in one or more compilation units can be grouped together and form a package. |
This is realized by the package statement, placed at the beginning of the compilation unit. |
A class Fred in package foo can be referenced by its full name foo.Fred, or by its local name Fred, after including the package import statement import foo; |
Packages can be nested. For example, a HTML Parser class has the following full name: net.www.html.Parser |
The initial alpha3 release of Java/HotJava is organized as 12 packages and it contains ~250 classes. |
This package is at heart of visual Java programming. It has functionality (and thus also complexity) comparable to X Windows or MS Windows. |
AWT offers an abstraction of a platform-independent window server. The same Java windowing code will run under UNIX (implemented via X Windows) and on PCs (implemented via MS Windows). |
Java/AWT is the latest and the most advanced offering in the long sequence of Sun efforts to set world-wide windowing standards. Previous unsuccessful attemps were:
|
Java class library comes with the on-line HTML documentation |
Each class API is documented, including all variables, constructors and methods |
Variable and method types are hyperlinked to the corresponding class pages |
Package and class navigation buttons are provided on each page |
Documentation skeleton is constructed automatically from the source code. |
Human-made text is constructed by extracting developers comments from the source code. |
This is facilitated by a special comment syntax |
/** text */ which marks chunks of text to be included into a suitable section of the documentation page. |
Applet bytecodes are downloaded by HotJava and executed on client machines. Security is therefore of crucial importance in the Java/HotJava model. |
The system implements several security measures listed below. |
C++ subset selected as a base model for Java does not contain explicit pointers, pointer arithmetic and uncontrolled automatic type coercion. This eliminates most viruses which are based on access to private memory areas on the client machine. |
There is also a multi-level runtime security system, including the following elements:
|
Applets are instances of a Java class called Applet and its subclasses. They can be embedded in HTML pages using the following tag:
|
where MyApplet is the name of a user-developed applet class, compiled by javac into MyApplet.class and placed in the subdirectory classes vs the virtual path of the HTML page. |
If the HTML page has the URL address:
|
then the file MyApplet.class pointed by the applet tag has the URL:
|
HotJava handles the <app> tag in a similar way as <img>, i.e. it inlines the content at the tag insertion point. Since Applet's content is Java code, this code is being downloaded and executed by the Java interpreter at the client side. |
Usually, applets contain some graphics and simulations which are being drawn/rendered/played on the HTML page containing the <app> tag. |
Base Applet methods are as follows:
|
For a minimal visual applet, one needs to specify init() and paint() methods. The full content and functionality of the Applet class is listed online. |
This is a "Hello, World" Applet in Java:
|
"Hello World" -- a sequence of applets, starting from "Hello World" and gradually adding text processing functionality from other Java classes |
WebFoil -- The last demo in the "Hello World" sequence, illustrating components of the prototype WebFoil --- a Java/HotJava based WYSIWYG interactive foil editor |
WebFlow Editor -- AVS-like visual network/compute--web editor for WebWork, prototyped as a Java/HotJava applet |
Project Manager -- A prototype WebFlow front-end for a distributed WebWork application -- software project management on a network of WebTools servers. |
Neural Network -- A telelearning application with Java/HotJava interactive front end -- character drawing pad for neural network algorithm which performs hand-written character recognition. |
A sequence of applets with gradually increasing complexity to illustrate various aspects of Java/Applet programming |
Starts with a minimal "Hello World" demo, evolves towards a prototype of the WebFoil viewer/editor/authoring tool |
Demo components:
|
Components 1--4 use only applet methods |
Components 5--10 extend applet functionality in terms of other classes: 5 uses threads, and 6--10 use AWT classes. |
Using AWT, each applet can be in fact extended to a full-blown interactive windowing application.
|
Hence, HotJava MenuBar can be customized and overloaded by applets (useful e.g. for developing and customizng educational browsers for various grades) |
Early prototype of components of an AVS-like visual compute-web editor. |
Two modes are supported and selected by a click on the appropriate marker in the lower bottom corner:
|
Right now, only the front-end part is prototyped and no linkage with the backend modules is provided (see Software Manager demo for a simple backend component). |
The goal of the project/demo is to gradually explore Java classes in the context of the planned advanced GUI application -- WebFlow editor. |
An early prototype of a WebWork application with WebFlow editor front-end: Software Project Manager tool. |
Three types of modules are supported:
|
Developers are assumed to use customized WebTools servers including CASE package for the software development. |
All software volume changes are monitored by the WebTools database and reported to the agent. |
Agent integrates and maintains the information, received from developers servers, and submits periodic status reports both to developers and to the manager. |
Example of interactive Web based telelearning "module" |
Backend Computation: Neural Network (Backpropagation) for hand-written character recognition |
Interactive Frontend Components:
|
In the current demo, backend is a C code developed at Caltech within C3P (Felten, Hutchinson, Otto). |
In the "Grand Challenge" limit (as per WebWork project) this could be replaced by a suitable HPCC computation. |
In the "Little Simulation" limit (in progress), a simplified version of the whole backprop code can be written in Java so that the whole Neural Network "module" can be downloaded and explored at the client/student side. |
Oracle Front-Ends -- simple Java interfaces to Oracle databases such as persdonal address book.
|
WebFoil "product" -- a tool for electronic presentation and Web navigation, constructed at NPAC in fall '95.
|
Java Collaboratory -- a skeleton environment for Web collaboratory applications.
|
SimLife gaming interface to NPAC HPCC simulation servers). |
Current web browsers are often used for electronic presentation but their page formating capabilities are inferior compared with presentation packages such as Persuasion or PowerPoint. |
In turn, these presentation packages are previous generation software, without any scripted extensions and Web compatibility. |
WebFoil brings these two currently disparate worlds together, by offering a web browser which is at the same time capable of formatting and customizing foils, viewed as Web pages. |
Note "foil" is a good unit for electronic presentation as (can be) designed to fit a computer screen and (can) have large fonts |
Current version NPAC WebFoil 0.1 is implemented as an extended HotJava application with enhanced page formatting and customization capabilities such as local font or color selection and margin control. |
Foils are edited, scripted and customized in extended HTML called FoilHTML via a set of custom attributes to be included inside the standard HTML tags.
|
NPAC WebFoil 0.1 is implemented as a standalone Java application (not an applet), constructed by extending HotJava version alpha3. |
The whole browser package from the Java/Hotjava release is overloaded by WebFoil.
|
All other packages, i.e. all "Java foundation classes" are left intact.
|
Apart from modifying browser package, WebFoil also adds one more class package called 'presenter'.
|
Right now (or rather after the conference after NPAC machines are back), WebFoil 0.1 can be remotely inspected at the following URL: |
http://naos.npac.syr.edu:2009/cgi/webfoil[?hostname:0.0] |
The part in square brackets [] is optional and useful if you use X terminal. For a regular X capable UNIX workstation, your DISPLAY variable will be set automatically by the WebFoil server. |
You should get a large blue window with dancing applet title saying "Hello HyperWorld --- WebWindows Start Here!".
|
Links to the source code, minimal documentation and examples are provided on the homepage. |
Links to tar files with organized 0.1 release will be enabled later in December '95. |