Next 24: Unix Power Tools  Up 23: Multimedia Prev 23.E: Animation  Contents

Specialized

§ 23.F:  ; Internet Programming Tools


For the ultimate in interactivity and control, nothing can beat writing your own program. The finest control can be found with programs written in standard programming languages such as C and Fortran. Many popular CD ROM titles are done this way. This level of sophistication is usually achieved by teams of experts (artists, programmers, writers and content experts). However, by using the internet and CGI-scripts or the Java programming language, we can obtain some of this control without nearly the level of expertise or manpower.

Scripts are simple programs which allow basic interactivity. A Web page is created which includes instructions for the user to enter information or select from a list. The user then "submits" the information and a short program (script) is run which creates a new Web page based on the information the user entered. If you have used one of the popular search engines, you have probably used a script. Because there are few limits on the type of operations a script can execute, most systems (the OSU Physics Cluster included) keep scripts in a protected directory which most users are not allowed to modify. Because of this restriction, we will stop our discussion of CGI-scripts here. If you become interested in CGI-scripts, you can find instructions and examples of almost any kind of script you might want on the internet, and you can ask the system administrator to allow you limited access to the CGI area.

Java is a programming environment designed specifically for the internet. It is relatively secure, so you can keep your programs in your own directory. Java, like C and Fortran, is a full-fledged programming language, and we will not make an effort to teach you how to program in it. However, a few quick notes about the nature of Java are in order.

Java is object oriented. This means that Java is intended to work best within a specific type of structure. If you do not know object oriented programming and you intend to do any complex Java programs, it is worthwhile to learn about object oriented programming (see Computational Physics by Landau and Paez).

Java is a secure language when run as an applet through a Web browser, but also exists as a stand alone language. This means that you may read about a specific Java command which you cannot use in your applet due to security restrictions. Most Java books contain a general list of applet security restrictions.

Java has been loaded on the OSU Physics cluster. If you are working on a machine which does not have Java, you can download it from Sun.

. For instance, We have included the program GraphApplet.java in the Java directory of your tutorial files. (This is one of the many sample programs which come with Java.) Change directories to Java and try compiling it with the "java compile" command javac:

After some time, the Java compiler will give you a new prompt signaling that it is done compiling and found no errors. If you do an ls, you will find that there is a new file GraphApplet.class. This is your compiled program.

There are two ways to run your Java applet. For testing, you will generally want to use the applet viewer (certain code, for example WebTerm, which involves socket connections or other low-level communications features may not run on the applet viewer). The other method is to use your Web browser. For either method you will need an HTML file to start the applet. The file example1.html has been provided for this purpose:

Pay particular attention to the command

This tells the browser to load the applet GraphApplet.class in a box of size width=300 height=120. Any time you wish to use a Java applet, you will need to include an applet tag like the one above in your HTML.

If you are working on an Xstation, try running your code on the applet viewer. Go to your window (not WebTerm) and enter the command

A somewhat boring example. Now try opening the file with your browser. If you are using Netscape, use the "Open" command under "File", then select the directory "Java" and press "Filter". Then select the file "example1.html" and press "OK".

Obviously, you will want to make more exciting programs to include on your Web pages. For advice on how to write simple programs in Java, we recommend the many examples available on the Web. For information on how to design more complex examples, we recommend a course or book which includes information on object oriented program design. If you are already an expert C++ programmer, you may find the book Java in a Nutshell by David Flanagan a useful and affordable reference.



Next 24: Unix Power Tools  Up 23: Multimedia Prev 23.E: Animation  Contents

Comments and questions to CP-unix@physics.orst.edu.