APPLET TAG - COMPILING CODE

You will learn a few REALLY important things in this lesson. This is the first lesson where you actually get to work with JAVA. SO, make sure you study this material REALLY carefully!

APPLET TAG: A simple applet tag must be inserted into an HTML page in order for an applet to load on that page when it is viewed in a Java-enabled browser. Most browsers are Java-enabled (or can easily be made to be able to run Java applets). Here's how you do it:

The important thing to realize about Java is that an applet is a little program which ACTUALLY RUNS on your web page as opposed to an image which just appears on your web page. You've had to make screen shots of your LOGO stuff to display it on a web page. You actually load the applet onto the page so it can run in a space provided on the web page. (This first example doesn't actually do much other than display some lines, but it had to be run which is very different from what happens when an image in shown on a web page.)

JAVA CODE: You create JAVA code in a text editter (JOE will work). Here's the code you will use for this assignment:


Here's the applet:

COMPILING THE CODE: After you have created and saved the file (which you should call sq.java), you are ready to compile it. Before you compile it run the dir command to see what files are in your directory. Then compile the .java file like this:

        javac sq.java

Run the dir command again and you should see a new file called sq.class.

ASSIGNMENT: You will present four major items on your web page:

  1. Code for sq.java in a textarea. You will need to study this page to see how to use the textarea tag. You should notice that the textarea is embedded inside of form tags.
  2. The sq.java applet which you compiled yourself.
  3. An image called sq.jpg which you create using LOGO which looks more or less just like the sq applet.
  4. The code you used to create the sq.jpg image in LOGO displayed in a textarea