(R561) Modifying a Simple Java Applet

Building an applet from scratch requires extensive programming in Java, a rather lengthy undertaking. Acquiring and modifying an existing applet for your own purposes is, however, rather easy to do. As an example, see if you can take my simple "My Wandering Mind-1" and modify it to run in your browser. You need to:


  1. Be sure that you have a "Java-capable" browser.

  2. Acquire the necessary source file and the Java applet HTML file from the person who wrote (or previously acquired) the Java script, and store them in the same directory. You typically get the source file (which ends in ".java") by clicking on "Save As..." in the Netscape FILE menu, and you get the HTML by clicking on "Document Source" in the Netscape VIEW menu.

  3. Compile the Java source code using the "javac" compiler in order to generate a set of ".class" files

  4. Create a link from your previous HTML file to the applet

  5. Modify the HTML script that specifies the parameters for the applet. Frequently you must edit out extraneous information, and get rid of the CODEBASE parameter.

  6. Activate the applet


Lets take each one of these in turn:
  1. Use a "Java-capable" browser: Netscape 2 and above and IE3 and above are all fine, but Netscape 2 cannot run Java on Windows 3.1.

  2. Acquire the necessary files: Let us make this concrete by assuming that you will copy these files from a subdirectory named Java in my public_html to a subdirectory named Java2 in your public_html directory. You do so as follows:

  3. Compile the Java code in your Java2 directory: to do so you must first switch to a related computer named ovid as we do not allow computer language processing on Homer. Homer and Ovid share the exact same file system. So you compile your Java program as follows:

  4. Create a link: Make a link from your previous HTML, for example your main index.html file, by inserting the string:
    <A HREF="Java2/larry-mind1.html"> My Applet </A> in it.

  5. Modify the file: Use any text editor to modify the file "larry-mind1.html": As a first step, I would simply replace my name with your name in the applet. In general, applets have the form:
         <TITLE> some title here </TITLE>
         Some text and HTML here
         <APPLET attributes>
         <PARAM NAME=parm VALUE=value,...>
         <PARAM NAME=parm VALUE=value,...>
         Alternate text here (for Java challenged browsers)
         </APPLET>
         
    In this case my applet looks like this:
         <TITLE>My Wandering Mind-1</TITLE>
         <H1>My Wandering Mind-1</H1>
         Below is a graphic applet with a number of nodes and their           
         relationships, illustrating my most basic interests!                        
         <HR>
         <APPLET CODE="Graph.class" WIDTH=600 HEIGHT=400>
         <PARAM NAME=edges VALUE="Larry-Food,Larry-MoreFood,Larry-LotsOfFood">
         <PARAM NAME=center VALUE="Larry">
         </APPLET>
         <HR>
         
  6. Activate the applet: click on "reload" in your "index.html" (if that is where your calling HTML is) and then click on "My Applet". For some reason, you may have to reload several time and possibly exit Netscape and re-enter it to get the applets to work correctly.


(R561) Modifying a Simple Java Applet
© Copyright 1997 UW C&C