Science and Computers -- PHY307/607

Lab 1. - Homepages and simple Java

In this lab we will learn how to create a homepage on the Web. This will allow us to use Netscape to view Java applets that we create in this and later labs.

Creating a homepage on SUnix

  1. If you are in one of the SU public clusters you will first need to login to the system. Do a CTRL+ALT+DEL to get a login banner (that is hold down all those keys at the same time). Type your SUnix username and password into the appropriate boxes (use the tab key to advance to the password box) If these are correct you will be presented (after some time!) with the usual Windows98 desktop (actually it's Windows NT but it looks pretty much the same).
  2. One of the desktop icons is named Secure Telnet. Double click it. A dialog box appears prompting you to select a SUnix machine to login to. Choose one - it doesn't matter which and login with your SUnix id again. Keep this window open for the whole session. These machines use an operating system called UNIX. UNIX is similar to DOS in that you communicate commands and actions to the machine by typing commands at a prompt. A list of simple UNIX commands is given as a link off the PHY307 homepage.
  3. Also, you will need to change the file permissionsfor your login directory to allow access by Netscape. Type the command chmod 711 . (notice that the period after 711 here is significant - it is UNIX shorthand for the current directory).
  4. Now type ls. This lists the files and directories (folders) that you have. All the Web pages you create must reside within a directory called public_html. You should already have such a directory.
  5. We will place all the PHY307 materials within a subdirectory (subfolder) of the public_html directory. First we need to access (open up) the contents of this directory. To do this type cd public_html. To create the new folder type mkdir PHY307. In order that this directory is viewable to the outside world via eg. Netscape you additionally have to change the permissions on it by executing the command chmod 755 PHY307.
  6. Change to this PHY307 directory by typing cd PHY307.
  7. Now you are in this directory use the simple text editor pico (see the handout describing how to use pico) to create your homepage in a file called Hwa1.html (type pico Hwa1.html).
  8. Insert the following lines into this file
    < html >
    < head >
    < title >  Yourname's homepage < /title >
    < /head >
    < body >
    < h1  > Yourname's homepage < /h1 > 
    Welcome to my Web page !
    ........................
    < /body >
    < /html >
    
    IMPORTANT -- there should be NO spaces between the < and > signs and the corresponding tag names.

    You can put whatever text and images you wish in place of the dots -- take a look at other SU students homepages at web.syr.edu. Exit pico by typing ctrl-x (the menu at the bottom of the pico screen shows all pico commands - the ctrl key is denoted by the hat symbol ^).

  9. Back at the UNIX prompt change the permissions on this file by typing the command chmod 644 Hwa1.html.
    Congratulations -- you have just created your own homepage on the Web. Check it out by pointing Netscape at web.syr.edu/~yourSUnixusername/PHY307/Hwa1.html.

Adding Java capability to your SUnix account

  1. Finally we would like to add our first applet to our homepage. Edit Hwa1.html to add the following line before the ending < /body > tag.
    < applet code=Hwa1.class height=200 width=300 > < /applet >
    
    Exit the editor saving this new version of Hwa1.html. At this point we have to supply the Java code Hwa1.class. We will download the source code for this from the PHY307 webpage.

Adding your first Java applet to your homepage

  1. Point Netscape at the PHY307 course page (www.phy.syr.edu/courses/PHY307). Go to the Labs link and there you should see both the text of the lab and a link to a Java source code (Hwa1.java). Select Save As to save this code to a file with the same name. Save the code to the subfolder public_html/PHY307 under your I: drive (the I: drive is mapped at login time to your SUnix filespace).
  2. Now we need to compile this source code into a form which can be executed. Make sure you are inside the PHY307 directory and from there type javac Hwa1.java. This should produce the file Hwa1.class in the same directory (don't worry about the warning produced by the compiler - this is usual and is not significant).
  3. Change the permissions on this file to make it world readable chmod 644 Hwa1.class.
  4. Now point Netscape at your homepage again (web.syr.edu/~yourSUnixusername/PHY307/Hwa1.html). Your homepage should now contain the simplest possible applet - the static HelloWorldApplet which merely prints HelloWorld to the page. This is not yet very exciting -- we will systematically improve on this applet in the next lab.
Once you have managed all this send me an email and I'll take a look ! (smc@physics.syr.edu). One possibility is to use pine which is a simple email program available on SUnix (just type pine at the UNIX prompt). Put lab1 as the subject and type the url for your homepage in the body of the email. Remember to Log off system before leaving the computer ! (select shutdown from the Start menu)

Back to the PHY307 Homepage

This page maintained by Simon Catterall, last updated 1 September, 2000.