Let's Taste Some Java

  1. Introduction
  2. What is Java
  3. Interaction
  4. Economics
  5. Virus Threats


With this issue I will begin an exploration of the new programming language Java. Emphasizing Java will allow coverage of many practical issues that are of interest to educators today while also solving a problem.

Of special interest to us all is the rapid ascendancy of the World Wide Web. Java is a vital ingredient in the recipe for web integration into mainstream commerce and education. Using Java in the creation of what we traditionally think of as applications is only one aspect of what Java can do. Web page creation and layout, user interaction, information delivery, and software/hardware cost structures are all enormously affected by the integration of Java.

The problem solved, is that examples given in this column can be directly implemented on any user's computer, through a web browser (even if not connected to the Web). Previous examples have been limited by platform/operating system incompatibilities, all of which, at least so far, are overcome by the programming language of Java. To begin, code examples will be given in JavaScript, which can be directly copied into your web pages and run from inside a browser. This use of JavaScript can bring interaction to your web pages as well as be a good introduction to Java programming. Java applet examples can be downloaded from my web site and run locally or placed in your own web pages.

What is Java?

Traditionally, a program must be rewritten for each computer type and OS (Operating System) the program is to be run on due to differences in APIs (Application Program Interface). A Mac OS does not respond to the same programming commands a Windows OS does. This interface between program code and OS is the API. As we all have experienced, programs written for Apple computers will not run on Windows computers or on UNIX for that matter. Even differences in OS versions can prevent programs from running properly. Java programs run an end pattern around the user's OS by executing inside a virtual machine, a kind of independent OS created in the user's computer (see Figure 1). The goal of Java programming is to write once; run anywhere, any time, forever.


Fundamentally, Java can create applications (programs) that match or surpass anything we have seen previously in commercial software. It is simply a very robust programming language. However, what most of us have seen of Java, to date, is not its application building abilities, but applets on web pages. Because Java is well suited to modern networking protocols, programmers have found it easy to create small programs, called applets, that display on web pages. These Java applets can only be executed from inside a web browser. Applets are most often seen, these days, as animation on web pages. Increasingly, Java applets are used for directly interacting with users. There really is little difference between what we traditionally think of as an application and an applet beyond the fact that an applet can only exist on a web page.

Remember that web pages are static and the HTML (Hyper Text Markup Language) used to create them is not a programming language. With Java, web pages can contain programs (applets) that fundamentally change what web pages do. Previously, the most a one could do on the web was jump through hypertext links, going from one static page to another static page. Now, a user can jump among interactive pages, running applets along the way, with no worry about PC type, OS version or local machine capacity.


One of the goals of this column has been to bring flexibility and creative solutions to bear on the problems so many of us face when dealing with questions of hardware. With update cycles that strain even the most generous budgets, valid questions can be raised concerning the cost/benefit ratio of computers in language classrooms today. Java fundamentally changes that ratio in favor of computer-based education.

Any program written in Java can be executed on any machine that contains a Java virtual machine. Presently, this means any computer capable of running a Java enabled web browser. To date, Netscape has the best coverage, with browsers for most major computer platforms and systems, including older ones such as Windows 3.1. In the near future, any newly released OS will contain the Java virtual machine so that Java applications can be run without the need for special installations or browsers. In the classroom, this means a room full of older machines, running "outdated" and different systems, which would traditionally be written off, can be given a new life. In fact, because Java software is actually running in the Java virtual machine, there is no need to worry about hardware or OS versions.

Even questions surrounding networking are more easily overcome with the use of Java. Applications or applets can be accessed over normal web connections, through local area networks or even distributed on floppy disks.

Virus Threats

Issues surrounding viruses are extremely important to anyone responsible for a computer lab. We often take extremely conservative stands in the hope of avoiding the immense troubles associated with computer viruses. It is no surprise that teachers express concern over running applications and applets on the Web. At a time when simply opening a Word e-mail attachment can spread a macro virus, the level of anxiety is naturally very high. The good news is that Java is 100 percent virus free and cannot spread a virus to a user's machine. The key reason for this security is the Java virtual machine. Every command sent to the user's computer must first travel through the Java virtual machine where it can be carefully inspected and rejected if it exhibits errant behavior. Additionally, browser security is very strict and does not allow Java applets to write to a user's hard disk beyond a few specialized file types.

In the next issue we will jump right into JavaScript examples that will liven up your web pages and open a world of possibilities for student interaction. Visit my web site for more details. http://www.cyut.edu.tw/~warden (click on the CÆLL logo)