Full HTML for

Basic foilset Java Tutorial - Spring 1998 Part 1:Introduction to Java Language

Given by Nancy J. McCracken,Tom Scavo,Geoffrey C. Fox at Jackson State CSC499 on Spring 1998. Foils prepared 12 Feb 98
Outside Index Summary of Material


Overview including History and alpha versus production issues
Comparison of Java and Javascript
Overall Java Philosophy and Features including security etc.
And in Remaining Parts of Tutorial!!
  • Java Programming Language
  • Object Oriented and Class Structure
  • Exceptions
  • Applet Programming and Threads
  • Abstract Windowing Toolkit
  • Networking and I/O
  • Futures and HPCC Implications

Table of Contents for full HTML of Java Tutorial - Spring 1998 Part 1:Introduction to Java Language

Denote Foils where Image Critical
Denote Foils where Image has important information
Denote Foils where HTML is sufficient
denotes presence of Additional linked information which is greyed out if missing

1 Java Tutorial - Spring 98
Part 1: Introduction to Java Language
Applications and Applets
http://www.npac.syr.edu/projects/tutorials/Java/
http://www.npac.syr.edu/users/gcf/javatutorial98.1/

2 Abstract of Java Tutorial
3 What is Java and What is Good For? for Foil 3 What is Java in a NutShell?
4 Java Resources for Foil 4 Resources for the Java Programming Language
5 Architecture of Java Applets
6 Incorporating Applets into
Web Pages

7 Running a Java Applet
8 Architecture of Java Applications
9 Java Applications in a Nutshell
10 The HelloWorld Application for Foil 10 The Simplest Java Application: Hello, World!
11 Java Applets
12 Applet Tag: Calling Applets from HTML - I
13 Applet Tag: Calling Applets from HTML - II
14 <PARAM> Tags and Applets
15 The HelloWorld Applet for Foil 15 The Simplest Java Applet: Hello, World!
16 title=The HelloWorldApplet.html file Displaying your applet in a Web page
17 Overview and History of Java Development
18 History of Java Language and Team
19 HotJava Browser History of Java Language and Team until Dec. 95
20 Java Text Books for Foil 20 Java Books -- I
21 Java Books -- II
22 Java Books -- III
23 Java Development Kit 1.0 JDK 1.0 -- The Java Development Kit!
24 Java Development Kit 1.1 JDK 1.1 -- Java grows!
25 Java Web Servers for Foil 25 Java Web Servers
26 Java vs. JavaScript
27 Comparison of Java and JavaScript I
28 Comparison of Java and JavaScript II
29 Overall Java Philosophy and Features
30 The Java Language Environment Some Key Java Features
31 Java Features -- It's Simple and Familiar!
32 Java Features -- It's Object-oriented
33 Java Features -- It's Architecture-Neutral
34 Java Features -- It's Portable
35 Java Features -- It's Somewhat Interpreted
36 Java Features -- It's Distributed
(and supports parallel computing)

37 Java Features -- It's Robust
38 Java Features -- It's (Hopefully) Secure
39 Java Features -- High Performance
40 Java Features -- It's Multithreaded
41 Java Features -- It's Dynamic
42 The Java Language Compared Sun's Comparison of Language Features I
43 Sun's Comparison of Language Features II

Outside Index Summary of Material



HTML version of Basic Foils prepared 12 Feb 98

Foil 1 Java Tutorial - Spring 98
Part 1: Introduction to Java Language
Applications and Applets
http://www.npac.syr.edu/projects/tutorials/Java/
http://www.npac.syr.edu/users/gcf/javatutorial98.1/

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Instructors: Geoffrey Fox
Nancy McCracken
Tom Scavo
Syracuse University
111 College Place
Syracuse
New York 13244-4100

HTML version of Basic Foils prepared 12 Feb 98

Foil 2 Abstract of Java Tutorial

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Overview including History of Java Development
Comparison of Java and JavaScript
Overall Java Philosophy and Features including security etc.
Java Programming Language
Object-Oriented and Class Structure
Exceptions and Threads
Application and Applet Programming
Abstract Windowing Toolkit
Networking and I/O
Futures and HPCC Implications

HTML version of Basic Foils prepared 12 Feb 98

Foil 3 What is Java in a NutShell?

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index What is Java and What is Good For? for Foil 3
What is Java?
  • A simple, object-oriented, distributed, interpreted, robust, safe, architecture neutral, portable, high performance, multithreaded, dynamic language
Java is interesting because
  • It is both a general purpose, object-oriented language similar to C++
  • It is designed to interface with Web pages and to enable distributed applications over the internet
The Web is becoming the dominant software development arena; this will drive Java as the best supported, most widely taught language
  • Particularly good as a language for K-12 teaching
  • Even outside the web, e.g., in scientific computing, Java is as good and in some (modest) respects better than all other languages

HTML version of Basic Foils prepared 12 Feb 98

Foil 4 Resources for the Java Programming Language

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index Java Resources for Foil 4
The original resource was the The Java Language Specification by Sun Microsystems, Inc., March 1995 updated to October 1995 but superceded by Gosling and Arnold Book
  • Addison Wesley has several other fundamental Java books on Application Programming Interface and Language Specification and Virtual Machine (by end of summer 1996)
Sun's web site http://www.javasoft.com/ has plenty of references including
Most of the books cited earlier have CDROMs with examples and the JDK.

HTML version of Basic Foils prepared 12 Feb 98

Foil 5 Architecture of Java Applets

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Browsers (HotJava, Netscape 2.0/3.0/4.0, Microsoft IE) supporting Java allow arbitrarily sophisticated dynamic multimedia applications called Applets, written in Java, to be embedded in regular HTML pages and activated on each exposure of a given page.

HTML version of Basic Foils prepared 12 Feb 98

Foil 6 Incorporating Applets into
Web Pages

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Applets are incorporated into web pages with
  • a special HTML tag:
  • <APPLET codebase="URL-directory-path"
    • code="Java-class-file-name"
    • width="w-pixels" height="h-pixels" >
  • where the URL and class file name point to a binary file that is to be downloaded and executed on the client side on each presentation of a page containing this <APPLET> tag. The applet executes in a window specified in size by width and height in pixels.

HTML version of Basic Foils prepared 12 Feb 98

Foil 7 Running a Java Applet

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Steps to running a Java Applet:
  • 1. Write an HTML file that refers to the applet using the <APPLET> tag, described later
  • 2. If necessary, write the Java code and compile into class file(s)
  • 3. Load the HTML file with a web browser or with appletviewer
Using a Browser
  • With a Java-enabled web browser, such as Netscape Navigator or HotJava, you run an applet by "surfing" to a web page containing the <APPLET> tag.
Using appletviewer
  • When developing an applet, use appletviewer to debug applets by specifying the HTML file on the command line:
    • appletviewer stock.html

HTML version of Basic Foils prepared 12 Feb 98

Foil 8 Architecture of Java Applications

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java applications are compiled and run on a machine just like any other general-purpose programming language such as C/C++. No web server or network are required although Java applications may also use network connections for distributed computing

HTML version of Basic Foils prepared 12 Feb 98

Foil 9 Java Applications in a Nutshell

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
All Java programs are written into a file with a ".java" extension
Java Applications are ".java" files with a main() method, which is excuted first
To compile and run a Java application:
  • Invoke the compiler on a ".java" file:
    • javac MyProgram.java
  • producing a file "MyProgram.class" of Java bytecodes
  • Run the interpreter on the ".class" file:
    • java MyProgram
  • which executes the bytecodes
The tools javac and java are part of JDK, which is available from Sun and has been ported to many platforms (Solaris, IRIX, AIX, and Windows 95/NT)

HTML version of Basic Foils prepared 12 Feb 98

Foil 10 The Simplest Java Application: Hello, World!

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index The HelloWorld Application for Foil 10
Since Java is object-oriented, programs are organized into modules called classes, which may have data in variables and functions called methods.

HTML version of Basic Foils prepared 12 Feb 98

Foil 11 Java Applets

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java applets are classes written in Java, which are intended not to run as stand-alone programs (as applications do) but as subprograms of a browser that is already managing a window
Applets should NOT have a main() method but rather methods init(), start(), paint() etc. that are invoked by the browser
The applet should be run through javac compiler producing a ".class" file as before: javac MyApplet.java
Also, create an HTML file (say "MyApplet.html") with an <APPLET> tag that loads "MyApplet.class"
Two ways to run an applet:
  • If you have JDK, run the applet with appletviewer
    • appletviewer MyApplet.html
  • Alternatively, run Netscape or Internet Explorer or some other Java-enabled browser, point the browser at MyApplet.html, and the applet is downloaded from the server and run by Java interpreter built into the browser. This requires that the ".html" and ".class" files are located in the document space of the web server
This way we develop where JDK installed but run almost anywhere!

HTML version of Basic Foils prepared 12 Feb 98

Foil 12 Applet Tag: Calling Applets from HTML - I

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Given the following HTML
<APPLET CODE="StockGraph.class"
  • CODEBASE="http://www.javasoft.com/applets/"
  • WIDTH=200 HEIGHT=200>
</APPLET>
Runs the "StockGraph.class" executable as an applet
WIDTH and HEIGHT are attributes that are passed along to the applet
If the optional CODEBASE attribute is provided, then load the executable from the directory specified by CODEBASE
  • Without CODEBASE, the browser will look for StockGraph.class in the local server's hierarchy (relative to where the HTML was loaded)
  • With CODEBASE, the browser will look for StockGraph.class relative to the given URL
Tag and attribute names are case insensitive

HTML version of Basic Foils prepared 12 Feb 98

Foil 13 Applet Tag: Calling Applets from HTML - II

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
<APPLET CODE="StockGraph.class" WIDTH=200 HEIGHT=200
  • ALT="-- StockGraph Not Supported --"
  • NAME=SUNW ALIGN=top
  • VSPACE=5 HSPACE=5>
Put text here for browsers that do not support Java
</APPLET>
ALT specifies text to be displayed if the browser understands the <APPLET> tag, but unable to run applets (i.e., Java-disabled)
NAME specifies the name of this instance of the applet; this makes it possible for applets on the same page to find and communicate with each other, and for JavaScript to communicate with Java, for example
ALIGN specifies the alignment of the applet. The possible values are the same as those available in the <IMG> tag (top, middle, bottom, texttop, absmiddle, baseline, absbottom, left, right).
  • Align=top aligns top of applet with top of tallest item in the line
  • Align=texttop aligns top of applet with top of the tallest text in the line
VSPACE and HSPACE specifies the vertical and horizontal spacing in pixels, around the applet space.

HTML version of Basic Foils prepared 12 Feb 98

Foil 14 <PARAM> Tags and Applets

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
The applet tag can be followed by parameters:
  • <applet . . . >
  • <param name=attributename1 value="attributevalue1">
  • .......
  • <param name=attributenameN value="attributevalueN">
  • </applet>
The Java program accesses this information by
  • String attribute;
  • attribute = getParameter("attributename1");
  • if( attribute == null )
  • attribute = somedefaultvalue;
  • // null is Java way of saying unset
Typically this processing would be in the init() method of the applet

HTML version of Basic Foils prepared 12 Feb 98

Foil 15 The Simplest Java Applet: Hello, World!

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index The HelloWorld Applet for Foil 15
Java applets can call methods to display graphics on the screen (within the browser window). This example overrides a public method paint() (defined in a superclass of Applet) and calls a method drawString() defined in the class Graphics.

HTML version of Basic Foils prepared 12 Feb 98

Foil 16 Displaying your applet in a Web page

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index title=The HelloWorldApplet.html file
The file must have the same name as your applet (e.g., HelloWorldApplet.java). Now run the compiler (javac), getting a bytecode file HelloWorldApplet.class, which is placed in a web directory (not a CGI directory!).

HTML version of Basic Foils prepared 12 Feb 98

Foil 17 Overview and History of Java Development

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index

HTML version of Basic Foils prepared 12 Feb 98

Foil 18 History of Java Language and Team

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Starts in 1991 by Project Green --- a group at Sun 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 UNIX emacs and 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 (Personal Digital Assistant -- 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.

HTML version of Basic Foils prepared 12 Feb 98

Foil 19 History of Java Language and Team until Dec. 95

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index HotJava Browser
An experimental web browser written in Java, called WebRunner and later renamed as HotJava, ready in 1994.
Alpha release of Java and browser HotJava April '95.
Netscape licences Java in May '95 and builds Java into Netscape 2.0 -- This confuses ownership and openness of Java
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.
In next week, SGI, IBM, Adobe, Macromedia, and finally Microsoft adopt/license Java. Java goes into open standards process and is adopted by Web community.

HTML version of Basic Foils prepared 12 Feb 98

Foil 20 Java Books -- I

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index Java Text Books for Foil 20
Teach Yourself Java in 21 Days, 2nd ed., by Laura Lemay and Charles L. Perkins, Sams.net Publishing, is a "how-to" book at the intermediate programming level, greatly expanded from the original edition.
Java in a Nutshell, by David Flanagan, is a language reference book in the familiar O'Reilly series. The 2nd edition of this book omits many examples from the first edition to make room for a large section on JDK 1.1 - currently best book reference. A separate book of examples is available.
Java, How to Program, by Deitel & Deitel, Prentice-Hall, starts with beginning programming concepts and progresses rapidly through Java language. It has the most programming exercises and also has companion teaching multimedia tools

HTML version of Basic Foils prepared 12 Feb 98

Foil 21 Java Books -- II

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
The Java Programming Language, by Ken Arnold and James Gosling, Addison-Wesley, May 1996, has lots of details on the language basics for intermediate and advanced programmers. It covers threads and I/O packages, but not applets or windowing packages.
  • All serious computer scientists should read this book to understand fundamentals
Java Primer Plus, supercharging Web applications with the Java programming language, by Paul M. Tyma, Gabriel Torok, and Troy Downing, Sams.net, doesn't assume a lot of programming background, has chatty explanations and still covers lots of programming detail.

HTML version of Basic Foils prepared 12 Feb 98

Foil 22 Java Books -- III

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
There are now many books in the Java Series from SunSoft Press, Prentice-Hall. Here are the first five:
  • Instant Java*, by John A. Pew, contains multimedia and animation applets for HTML authors. This is not a programming book.
  • Java By Example, by Jerry R. Jackson and Alan L. McClellan, covers all key features with examples, but not as much detail about the language.
  • Just Java, by Peter van der Linden, for intermediate programmers, gives good explanations of key features without going into detail.
  • Core Java, (two volumes) by Gary Cornell and Cay S. Horstmann, offers detailed coverage of the language and packages for experienced programmers. Second edition covers Java 1.1
  • Graphic Java, by Gary McClellan, gives more details on windowing and user interface and includes new classes (not in originial Java release) for such things as "rubberbanding".
* this title is great, but what happened to "express Java", "Percolating through Java", and "Java for Drips"?

HTML version of Basic Foils prepared 12 Feb 98

Foil 23 JDK 1.0 -- The Java Development Kit!

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index Java Development Kit 1.0
The beta version of Java, Version 1.0 of JDK released January 96 by JavaSoft
JDK 1.0 becomes the Internet standard and so compatible with ongoing Java implementations by all licensees, most notably Netscape and Microsoft. JDK version 1.0.2 includes:
  • Java compiler (.java to .class) for Sun Solaris, Windows NT/95, and Macintosh (written in Java) but no source
  • Java interpreter to execute bytecodes (.class), including source code
  • Java foundation classes, including source
  • appletviewer to run/preview applets
  • Java prototype debugger (command-line version)

HTML version of Basic Foils prepared 12 Feb 98

Foil 24 JDK 1.1 -- Java grows!

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index Java Development Kit 1.1
A substantial new version of Java released in March 97
This release includes many developments by Sun and partner companies such as IBM. There are minimal changes to the language --- primarily development of new classes to support enterprise computing.
Included in JDK 1.1 are: core library (including source), Java compiler (javac), Java interpreter (java), Java runtime interpreter (jre), appletviewer, debugger (jdb), disassembler (javap), documentation generator (javadoc), C header and stub file generator (javah), archive tool (jar), signing tool (javakey), plus numerous other tools (native2ascii, rmic, rmiregistry, serialver, and updateAWT)
  • Netscape4.0 and Internet Explorer 4.0 support JDK 1.1
http://java.sun.com/products/jdk/1.1

HTML version of Basic Foils prepared 12 Feb 98

Foil 25 Java Web Servers

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index Java Web Servers for Foil 25
Originally, the Java interpreter was incorporated into browsers such as those from Netscape and Microsoft, but the Web server remained a standard one.
Now Web servers are being developed in Java itself. This leads to more natural integration of the use of Java applets on the Web browsers and Java applications running on the Web server machine.
  • Java WebServer from Sun - http://jserv.javasoft.com/ - This web server is developed following new Java Server API, which allows for security and encryption servers. WebServer will run Java applications, called servlets, on the server side similarly to CGI scripts.
  • Jigsaw from the W3 Consortium - http://www.w3.org/Jigsaw/ - This web server has the most services but is currently being rewritten so that the model for running Java on the server side will be JavaBeans.

HTML version of Basic Foils prepared 12 Feb 98

Foil 26 Java vs. JavaScript

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index

HTML version of Basic Foils prepared 12 Feb 98

Foil 27 Comparison of Java and JavaScript I

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Netscape renames LiveScript as JavaScript. The latter is fully interpreted (code can be included directly in HTML file) and used for overall customization of client
Use Java for detailed programming and JavaScript for overall integration of client interface, for example
JavaScript: Interpreted by client and NOT compiled
Java: Compiled on server before execution on client
  • Note both are reasonably "pure" C/C++ like languages and do NOT have useful sh/awk text and system enhancements of Perl5 (except for JavaScript 1.2, which supports Perl4-like regular expressions)
JavaScript: Object-based, no classes or inheritance; built-in extensible objects
Java: Object-oriented; programs consist of object classes with inheritance

HTML version of Basic Foils prepared 12 Feb 98

Foil 28 Comparison of Java and JavaScript II

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
JavaScript: Tightly integrated with HTML
Java: Applets distinct from HTML but invoked from HTML pages
JavaScript: Loosely typed---in general, variables not declared
Java: Strongly typed---all variables must be declared
JavaScript: dynamic binding---object references determined at runtime
Java: static binding---object references determined at compile time
Java and JavaScript are secure and cannot write to disk
JavaScript has most user interface components of Java (buttons, frames, etc.), even mouse actions in JS 1.2

HTML version of Basic Foils prepared 12 Feb 98

Foil 29 Overall Java Philosophy and Features

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index

HTML version of Basic Foils prepared 12 Feb 98

Foil 30 Some Key Java Features

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index The Java Language Environment
Document The Java: A White Paper by Sun Microsystems -- October 1995 draft by James Gosling and Henry McGilton -- expounds on the original design of Java:
Simple and familiar
Object-oriented
Architecture-neutral
Portable
Somewhat Interpreted
Distributed
Robust
Secure
High performance
Multi Threaded
Dynamic

HTML version of Basic Foils prepared 12 Feb 98

Foil 31 Java Features -- It's Simple and Familiar!

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java omits several rarely used, poorly understood, and confusing features of C++, including operator overloading, multiple inheritance, pointers, and automatic type coercions.
It adds automatic garbage collection, which makes dynamic programming easier in Java than in C or C++.
  • No more mallocs!
It also adds 'Interface' construct, an Objective C concept, which often compensates for the lack of multiple inheritance by allowing method calling syntax to be "inherited".
The resulting language is familiar, as it looks like C++, but is simpler and hence easier to program in.
It also results in a much smaller kernel, which is suitable for Java ports to consumer electronic devices. Base (alpha) interpreter is ~40Kb, libraries and threads add additional 175Kb.

HTML version of Basic Foils prepared 12 Feb 98

Foil 32 Java Features -- It's Object-oriented

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java model can be viewed as a C++ subset, with some dynamic elements inherited from Objective-C (method overloading, garbage collection).
Structures, Unions and Functions are absorbed into data and methods of Java classes -- Java is Simple!
The strength of Java object-oriented model is not its sophistication, but in simplicity and the extensive class library associated with the system (some 250 public classes were released initially).
Java class also plays a role of a communication entity 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.

HTML version of Basic Foils prepared 12 Feb 98

Foil 33 Java Features -- It's Architecture-Neutral

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
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 written for the "Java Virtual Machine"
Java compiler (written in Java and platform-independent) reads Java source and generates Java bytecodes (.class files). These bytecodes are shipped to client machines upon browser request.
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.

HTML version of Basic Foils prepared 12 Feb 98

Foil 34 Java Features -- It's Portable

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java language offers a uniform abstract (virtual) machine model, which is identical for all platforms
SUN owns the Java Virtual Machine (see online report) -- it is universal, but classes can be added by any user
Unlike C/C++ where various integers match the architecture of a physical machine at hand, Java byte, char, short, int and long are always of the same size, equal to 8, 16, 16(unicode), 32 and 64 bits, respectively.
  • No header files, preprocessors,#define etc.
  • floating point is always IEEE 754
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 (alpha) 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.

HTML version of Basic Foils prepared 12 Feb 98

Foil 35 Java Features -- It's Somewhat Interpreted

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
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 that is portable and much smaller than the real binary for a specific machine (typical bytecode size is on the 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.

HTML version of Basic Foils prepared 12 Feb 98

Foil 36 Java Features -- It's Distributed
(and supports parallel computing)

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Popular TCP/IP based protocols such as FTP or HTTP are supported in terms of network protocol classes.
  • This facilitates message passing and immediately supports various forms of distributed processing.
  • New protocols, such as PVM and MPI, can be added and dynamically installed.
  • Parallel computing can be built on top of these base classes.
Distributed computing model of Java is mainly client-server, with Java compiler preparing the bytecodes on the server side, and the Java interpreter executing the bytecodes on the client side.

HTML version of Basic Foils prepared 12 Feb 98

Foil 37 Java Features -- It's Robust

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java enforces compiler-time type checking and eliminates some error prone constructs of C/C++.
Pointer arithmetic is totally eliminated, which allows e.g. runtime checking of array subscripts and enforces security of the Java model.
Explicit declarations are always required, i.e., C-style implicit declarations are forbidden. This allows the Java complier to perform early error detection and give good error messages.
Rapid prototyping in Java is less natural than in JavaScript, Lisp, Tcl, Smalltalk, or Perl, but the software quality assurance of Java is higher than in these more dynamic and 'forgiving' languages.

HTML version of Basic Foils prepared 12 Feb 98

Foil 38 Java Features -- It's (Hopefully) Secure

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java bytecodes are shipped across the network and executed on client machines. Security is therefore a critical issue and strongly enforced in Java.
  • Java contains its own networking classes, which are designed to be secure
Modifications of the C++ model such as eliminating pointer arithmetic and type 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 bytecodes are executed on the client side by the Java interpreter, which operates exclusively on 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 writing applets.
The bytecodes sent across network are verified on the client, which prevents evil/corrupted classes from causing problems

HTML version of Basic Foils prepared 12 Feb 98

Foil 39 Java Features -- High Performance

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java interpreter performs on-the-fly runtime execution of the Java bytecodes, which results typically in a satisfactory performance.
  • NOT true in initial releases, which were often 100 times slower than C
  • performance is improved in new "just-in-time" interpreters, which pre-compiles bytecodes to provide compiled code efficiency
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).
Java/HotJava system implements ANDF concepts for the Java language.

HTML version of Basic Foils prepared 12 Feb 98

Foil 40 Java Features -- It's Multithreaded

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
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 browser to handle multiple document dynamics.
Another interesting application domain are multi-HotJava environments such as collaboratories or games.
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.

HTML version of Basic Foils prepared 12 Feb 98

Foil 41 Java Features -- It's Dynamic

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index
Java model is more dynamic than C++ and closer to Smalltalk or Perl.
Subclasses don't need to to be recompiled after superclass implementation is updated.
C++ has "fragile superclass" problem where children must recompiled if anything changes (method/instance variable) in a superclass or referenced class -- Java resolves references at runtime and avoids this.
Classes have runtime representation (implemented in terms of the Class class), which allows one to look up type of a given object instance at runtime (in C cannot know if pointer is to integer or browser!)

HTML version of Basic Foils prepared 12 Feb 98

Foil 42 Sun's Comparison of Language Features I

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index The Java Language Compared

HTML version of Basic Foils prepared 12 Feb 98

Foil 43 Sun's Comparison of Language Features II

From Java Tutorial, July 1, 1996 Jackson State CSC499 -- Spring 1998. *
Full HTML Index

© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998