Exercise 4: Java Applet - Hello World

For a detailed Java information see The Java Tutorial.

Write a Java applet which prints "Hello World!" in a Netscape browser.

  1. First move into your web directory.
        $ cd www
  2. Create a file called HelloWorld.java and type in the program given in class.
        $ vi HelloWorld.java
  3. Compile the source file.
        $ javac HelloWorld.java
  4. Create the HTML file needed to display the applet.
        $ vi HelloWorld.html
    HelloWorld.html will look like the following:
    <TITLE>The Hello World Applet</TITLE>
    <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
  5. To check your results open the HelloWorld.html file in your browser.
Exercise 4 is due Thursday March 2. We will look for the HelloWorld.java, HelloWorld.class, and HelloWorld.html files in your www directory.