CSci 220 - Lecture 22

Web Page Design

© Morris Firebaugh


Integrating Java Applets and HTML


A. JAVA - The Universal Language

How the experts define Java:

Java is a simple, robust, secure, object-oriented, platform-independent, dynamic programming environment.

Sun Microsystems

Java is a simple, object-oriented, distributed, interpreted, robust, safe, architecture neutral, portable, high-performance, multithreaded, dynamic language.

Ken Arnold, Sun Microsystems

Java is a full-featured programming language whose programs (called applets) can travel over the Internet.Whereas plug-ins are tailored for a particular computer system, Java programs operate across the network, regardless of platform. Because Java capabilities are built into Communicator, Java applets require no installation.

Netscape's Help

A Short History of Java

Two excellent references by Sun  -  please use them

B. Features and Syntax of Java

Java is strongly Object-Oriented

Philosophy of OOP:

Objects combine an abstract data type and a set of methods that manipulate that abstract data.



Java Features

involves elements and concepts such as

The following are Java Keywords

abstract boolean break byte byvalue
case cast catch char class
const continue default do double
else extends false final finally
float for future generic goto
if implements import inner instanceof
int interface long native new
null operator outer package private
protected public rest return short
static super switch synchronized this
throw throws transient true try
var void volatile while

The 11 italicized keywords are reserved, but not used, in release 1.0 of Java.

So the language is defined in terms of (59-11) = 48 keywords.



Supported Java Types include:

Nomenclature of Java Objects

In simple example below,

		class HelloWorld {
		      public static void main(String args[]) {
		           System.out.println("Hello World!");


C. Examples of Java Applets

Some of the nicest examples and links to an excellent tutorial are by Daniel Nichita, a student in biomedical engineering at the University of Southern California.

The Java Development Kit (JDK) is available free from Sun Microsystems


D. Introduction to Java Applets & Programs

Java runs in two "modes"


Example 1: Create a Java StandAlone Program Source File

Using a text editor, create a file named with the following

Java code: 

* The HelloWorldApp class implements an application that
* simply displays "Hello World!" to the standard output.*/
class HelloWorldApp {
                      public static void main(String args[]) {
                          System.out.println("Hello World!"); //Display the string.


Compile the Source File


Example 2: Create a Java Applet

Create a Java Source File

        import java.applet.Applet;
        import java.awt.Graphics;
        public class HelloWorld extends Applet {
                public void paint(Graphics g) {
                        g.drawString("Hello world!", 50,25);


Compile the Source File


Create an HTML File that Includes the Applet


        <TITLE> A Simple Program </TITLE>
        Here is the output of my program:
        <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>


Run the Applet



E. Laboratory Assignment # 11


 Updated 4/5/2000