Anyone Else for Java?

If you don't see a title in changing rainbow colors at the top of this page, your browser does not understand the Java language. Try the latest version of Netscape or HotJava!


Hello! Anyone else for Java?

On March 5, 12, 19, and 26, I offered a mini-course on Java for the Department of Earth and Space Sciences (ESS) that was entitled Anyone for Java? The present course is a two-session version of that workshop, and will be conducted from 5:00 to 7:00 pm on April 30 and May 7 in the Endeavor Hall "War Room". For examples of some of the Java applets that students at SUNY Stony Brook have created under the guidance of faculty and staff of the ESS Department, see Project Java. Please email me at Glenn.Richard@sunysb.edu if you have any questions about Java or this course.

- Glenn Richard

The Java programming language is rapidly increasing in popularity for developing interactive programs that are capable of running in browsers that access the World Wide Web. While Hypertext Markup Language (HTML) is designed for describing the format of documents, Java is a full-featured interactive programming language. It was designed by Sun Microsystems, originally for programming appliances like toasters and coffee machines. However the name of the language has nothing to do with that. Back in the early days it was known as *7 (Star Seven). Several name changes were made after that, to Green, and then OAK. It turned out that another language had already been christened as OAK, so a new name was needed. Someone who was a regular visitor to a certain coffee shop in Palo Alto, California liked a saying that was tacked to the wall that read It's a jungle out there, so drink your Java!.

This workshop is being offered at a transitional time in the evolution of Java. For all practical purposes, the language specifications are defined by Sun's free Java Development Kit (JDK), and version 1.1.1 has just been released. This renders obsolete the numerous books that have recently appeared on the subject along with several commercially available development environments. Undoubtedly, these will soon be updated, but it has left me in a quandary. Should I use a friendly, but obsolete, development environment for this course, or should I use the up-to-date, but not-so-friendly JDK? I have decided to go the unfriendly route, because the JDK can do anything that the commercial packages can, and I believe that the details of the language are more important than a cozy development environment, when we cannot have both.

We will create our own slightly friendly environment by using three windows:

  1. The Notepad text editor for writing Java code
  2. A DOS window for using the javac compiler
  3. A second DOS window for running Appletviewer

DOSKEY should be invoked in the two DOS windows to reduce the amount of typing and distraction we experience. First, we need to create an HTML file that references our applet. An example would be:

<applet code="HelloWorld.class" width=300 height=100>
</applet>
For convenience, our HTML file will have the same name as the Java class it references, but with .html as an extension instead of .java. In the above example, it is assumed that our Java code resides in a file called HelloWorld.java. Therefore, out HTML file is HelloWorld.html.

After creation of the HTML file, our development cycle will iterate as follows:

  1. Write or modify Java code in Notepad and save it in the .java file
  2. In the first DOS window, compile the Java code (javac filename.java), which creates a class file named filename.class.
  3. In the second DOS window, invoke Appletviewer (Appletviewer filename.html), look at the applet, then exit Appletviewer.

For steps 2 and 3, the up-arrow will bring the last command up on the screen as long as DOSKEY was invoked, and all we have to do is hit Enter to execute it. This will help prevent carpal tunnel syndrome.



Session 1: Building with Objects and Responding to Simple Events
Session 2: Graphics, Threads and Animation

Get Sun's Java Development Kit now!

Last modified May 14, 2002


[Project Java home] [CHiPR home]