## Sun's Java Language - An introduction

This is a document in three parts:

1. Introduction - Brief history of Java, Definition of terms, scope of this introduction
2. Applications - Specifications, possible uses, what I did with Java
3. Conclusions - What it all means

### Introduction

In this document, I hope to provide a concise, accurate introduction to the Java programming language and its applications and potential on the Internet.

Java was developed as a response to problems programming in C++. It is intended to be a "simple, object oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high performance, multithreaded, dynamic" (1) programming language.

Although it can be used to write stand-alone applications, the concept of "applets," or little programs, which could be included with HTML documents and distributed over the Internet caught on, and led to the development of HotJava, Sun's Java-capable browser. HotJava is in most respects a fairly typical graphical Web browser along the lines of Mosaic (although it does support some Netscape HTML extensions). However, it was designed with these applets in mind; it supports the (not-yet-standard) APP HTML tag, which implies a Java program. The Netscape Navigator web browser's new 2.0b? versions add support for the emerging beta-standard of Java as well. Currently, only the 32-bit (NT and '95) Windows versions and the HP-UX, IRIX, and SunOS and Solaris ports are Java-enabled. Supposedly they're working on Java capable Macintosh, Linux and BSD-ish Navigators, to be released Real Soon Now[tm].
A Java-capable browser, once it sees an of these APP tags, will download the code for the program described therein, and attempt to compile and run it on the client's machine. All HotJava distributions, and, one would assume, future implementations of the language, include standard libraries, an interpreter and compiler, and several pre-compiled examples of applets.

There are considerable security issues inherent in having potentially thousands of these applets downloaded and executed on a distributed basis across the Internet. Malicious or mischevious use could be devastating for companies and individuals' computers, but Sun says there is very little to worry about. They have built a multi-layer model of security into the language, compiler, and the browsers; for a detailed discussion of how it works, check out this page at the javasoft site.

### Applications

Intrigued by the possibilities, I downloaded both available distributions of the HotJava browser: one for Sun Solaris, which I compiled and ran on a Sparc 1 with Solaris 2.3; and the second for Windows NT (v3.5) which I installed on a P75. The distribution is quite large: the Sun version is almost 24 Megs, and the NT's is ~20 meg. I started with the canonical "hello world" program as illustrated in the Java FAQ:

    import browser.Applet;
    import awt.Graphics;
    class HelloWorld extends Applet {
            public void init() {
                    resize(150, 25);
            }
            public void paint(Graphics g) {
                    g.drawString("Hello world!", 50, 25);
            }
    }

and lo and behold it worked. Java gives you greater control over the placement and attributes of text than does HTML 2.0, as you can define colors, placement, and other styles at runtime, a philosophy which provides a middle ground between HTML/SGML's client-specific layout and the stricter design requirements of Adobe's PDF or traditional print media.

It worked so well I decided to tackle one of the thornier problems of web design: animation. An animation applet is one of the demonstration programs, so all I had to do was modify our Planet Hawaii animation graphics to work with the Java syntax. This is where I started to get really impressed with Java. It only took minor debugging (the cache-flushing function of HotJava's Alpha release isn't perfect), and once it ran, it ran.

This is a MUCH more elegant implementation of inlined animation that Netscape's kludgey server push/client pull gimmick. The animation was relatively small, about 1 1/2 inches square, so the twelve graphics it animated were a total of about 15K. This is minimal download time, (nonexistent in local mode :-) and the animation is smooth. Since it cycles through the images on the client's machine, the loop doesn't start running until all of them are downloaded and ready to go. There are also easily-configurable options such as how many times to loop, pauses, etc.

Beyond the animation came practical applications, some of which I coded and some of which I merely looked at. There are some impressive (and fast) ways to animate headlines, rotate 3d models, etc.

### Conclusions

I'm rewriting this part as of the Last modified: tag below. Since I started this document, Netscape has come out with its implementation of java and of JavaScript, a stripped-down version of the spec. here are my test pages. No guarantees that your browser won't self-destruct though.

### Caffinated Links

Information on Perl/CGI programming
Check out my homepage
Yahoo's Java tutorials
Nelson Yu's page of other unfinished Java guides :-)

Document last modified by Eric Sorenson, eric@aloha.net.