Department of Computer Science The University of Western Australia

Concurrent Programming (230.304)


The Laboratory Environment: Getting Started on Windows NT and Java

This document has been modified (with permission) from Exercise 2 of CS220

The aims of the document are to:

  1. Introduce you to the Windows NT operating system.
  2. Provide information about the Netscape Web browser.
  3. Introduce you to the Java compiler and interpreter.
  4. Show how the browser can be used to get further information.

The Windows NT operating environment grew out of Microsoft's MS-DOS operating system, and now incorporates many windowing features of a similar type to those found on Apple Macs, as used in the first year course. It and its relatives (Windows 3.1, Windows for Workgroups, Windows 95) have since become the dominant (in terms of sheer numbers) commercially produced environment for personal computing.

1. Logging on to Windows NT

When you arrive in the Lab your machine should show one of the following:

  1. A welcome window asking you to press Ctrl+Alt+Del to log on. In this case Windows NT is running.
  2. A Linux window with the full name of the computer and a login prompt. For example: pent-007.cs.uwa.oz.au
  3.       login: 
          Password:
    

    This is the Linux operating system.

If the Linux prompt is shown, press Ctrl+Alt+Backspace immediately followed by Ctrl+Alt+Del to reboot the system. When the Lilo Boot: prompt appears, type nt and press Enter (otherwise it defaults to a Linux reboot). After a few minutes the Windows welcome window will appear.

Once the welcome window has appeared, press Ctrl+Alt+Del to get the login window. Then enter your username and password. A student named Zebediah Zzyp will have a username of zzyp-z and a password will have been chosen for them.You will then be logged on to the machine and a number of icons will appear down the left hand side of the screen. (You may also see a welcome window with a `hint for the day' which you should close before proceeding.)

Try launching the "My Computer" icon. A window should open showing icons including one for the "C" drive (the computer's own hard drive) and one for the third year area on Kaluta (also called the "Z" drive). Kaluta is the NT file server for all undergraduate accounts and will be where you store your work. This enables you to see your files from any of the NT machines. If you launch the icon for Kaluta you will get a new window showing folders (or directories) for all the third year students. We will return to this later when we discuss file systems.

If you have more than one window on the screen, then only one of them will be active (any key strokes you type, for example, will be interpreted by that window). The active window is selected in the same way as an icon - simply move the mouse over the window and single-click the left button. If the windows are overlapping, this also brings the selected window to the front. You can move a window to a different position on the screen by moving the cursor into the top border, holding the left-hand mouse button down and then dragging the window to its new position. You can change the size of a window by "dragging" (click and hold down the mouse button then move the mouse) any of the other borders of the window. The button with an "X" at the top right corner of a window will close that window. The button to the left of this expands the window to fill the screen, and the third button iconifies the window. To get a feel for this try changing between the "My Computer" and Kaluta windows that you have open, moving them about and resizing them. Then close them.

Most of the applications that you will run will be launched via the "Start" button at the bottom left of the screen. Click on this button to pop up the menus and have a quick browse through them.

2. The Netscape Web Browser

A Web site (the CS304 Home Page) will be used to provide some of the source materials for the course. We will see how this page can be accessed using the Netscape Navigator browser.

To start the Netscape Navigator, from the "Start" button pop-up menu move up to "Programs," then in the submenu that appears to the right move down to "Netscape Navigator" and finally across to "Netscape" and click the left mouse button. This will launch the Navigator. In future we will abbreviate sequences of menu choices, such as the above, in the following style: [Start|Programs|Netscape Navigator|Netscape].

Windows NT also provides the Microsoft Explorer browser. As well as being accessible via the Start button, it can be launched directly from the icon on the left side of the screen. You might like to try this and compare it with Netscape. Note however that the course Web Pages (and many of the pages in the Department) are designed chiefly for viewing by Netscape. You can still view them with Explorer or any other browser, but they may not appear exactly as intended.

The Netscape Navigator will appear essentially the same on both the NT and Linux systems. There may be small variations if different versions of the Navigator are available on the two systems. At the time of writing this exercise sheet, the Linux system had available Netscape Navigator Gold 3.01, while the NT system had the older Netscape 2.01.

When run for the first time Netscape may come up with a window asking you to read and acknowledge some licensing and usage conditions. When you have accepted these conditions (after reading them of course) a Netscape window should appear with the Department of Computer Science's Home Page in it. If this page does not appear click on the button at the top of the page that is labelled "Home" and has a little icon of a house on it. If it still does not appear choose [Options | General Preferences] and change the Home Page location to http://www.cs.uwa.edu.au/ and then click the Home button.

A Web browser allows you to view hypertext documents, as well as performing file transfers and a number of other functions. A hypertext document is a virtual document in the sense that the individual parts of the document can be stored on different computers anywhere in the world. The parts of the document are connected by links. As the links can point anywhere the sections of the document need not be organised in a linear order (like a book), but can have any topology.

Have a look at the Computer Science Department's Home Page. If you scroll the page you will see a range of information about the Department, some of which is underlined and highlighted in blue. These are the links to other pages. As an example, find the line which says "Undergraduate teaching" and click on the highlighted blue word. A new page should appear with headings like "Second year", "Third year" etc. Try following the link "Third year".

As with most applications, you can change the way things appear on the screen from the default by using the "Options" menu. For example you can change the size of the browser fonts which can be useful if you wish to see more on the screen, or have trouble reading the smaller fonts.

As you traverse the Web, the browser keeps a hierarchical record of where you have been. You can return to the previous location by clicking the "Back" button at the top of the browser. Press this now to return to the previous page. You will now see that "Third year" is highlighted in a different colour to the other links. This tells you that you have visited that location recently and is helpful when you are searching for information, or "surfing the Web". Unfortunately it costs the CS department real money for every byte of information downloaded from outside the Perth local area (PARNET), so undergraduate students are restricted to surfing within the Perth area.

Now we will move on to the CS304 home page and locate the online version of the document that you are now reading! The online version will be more useful than the printed version because it can point to further information through the use of links.

2.1 The CS304 Home Page

There are several ways of reaching the CS304 page. For example you can click the "Open" button on the browser, type in the full address directly

and click "Open in Browser".

An address like this is called a Uniform Resource Locator (URL) and contains information about the format and location of the document. (The http says to expect a document in the HTTP format, the www.cs.uwa.edu.au is the address of the computer on which the document is located, and the teaching/cs304/index.html is the location of the file on that computer.)

If you know that you will be coming back to this page frequently, you can put a "bookmark" in this page by selecting [Bookmarks | Add Bookmark] from the menu at the top of the browser. Then you can return to the page at any time by selecting [Bookmarks | Concurrent Programming (CS304)] from the menu. You should bookmark the CS304 Home Page as you will be using it several times a week.

The CS304 page contains a variety of information about the course, for example, Laboratories and Tutorials. This information will be expanded over time.

Be aware that Netscape will cache (save) copies of the most recently downloaded pages and present you with the cached copy of a page if it is still available. (The cache is because it is likely that you will refer to a document repeatedly over a short space of time, so Netscape just downloads it once). The "Reload" button should force Netscape to download a new copy (although on some machines it seems necessary to press "Reload" more than once) of the page.

When using Netscape under NT you will be able to print out pages by selecting [File | Print] from the menu at the top of the browser, provided a printer has been installed. So if you lose a sheet or a lecture note or something then you can easily get another copy. HOWEVER, please note that one of the main aims of online documentation is to save trees, so use this option sparingly. It is almost always inappropriate to print out documentation as documentation is usually used for reference, rather than reading. You will be supplied with photocopies of lecture notes and exercise sheets (it is much cheaper to print once and photocopy often). Printers, paper and toner are all expensive so please bear in mind that the Department can only absorb a certain cost, and access to printers will have to be severely restricted if they are over-used.


Task:. Load the online version of this document. You can find it by following the link to "Laboratories" and then the link to "The Laboratory Environment" from the CS304 Home Page or by using the URL:

Continue working through this exercise sheet using the online version.


3. Getting Familiar with Windows NT

We now return to looking at Windows NT in more detail.

The first task is to change your password. Under NT you do this by pressing Ctrl+Alt+Delete and selecting "Change Password" in the window that appears. This brings up a new window in which you can enter your old password and then the new one (twice, to avoid typos). Press "OK" when finished.

In Windows NT, most applications have their own "Options" or "Settings" menu. For example, launch [Start|Programs|Accessories|Clock]. This will pop up a clock which you can leave open on the desktop so that you don't find yourself so engrossed in the joys of Java programming that you miss the last bus home! Click on the "Settings" menu. You will notice that you can select between digital and analogue, select whether seconds are shown, and so on.

Most applications have their own help pages. For example, launch [Start|Programs|Accessories|Telnet]. This will open a Telnet window. Telnet is a program that you can use to open a terminal window (like the xterm windows under Linux) logged into another computer. So, for example, if you are using Windows but want to run a Linux command on your Linux filesystem (say you read your mail under Linux) you can do it through a telnet window. For help on using Telnet, just click on the "Help" menu at the top of the window. You can also get general help about Windows and its applications at any time by clicking on (selecting) the background and pressing the "F1" key.


3.1 The File System

The NT file system is an hierachical structure, consisting of many directories, each of which can contain files or other directories. It is important to understand how to use directories so that you can organise your work. In Windows, since there is (in general) no command line, there is no notion of the "current working directory" other than perhaps the directory associated with the selected window. The notions of absolute and relative path names, root directories, home directories and subdirectories still apply, but they are normally viewed by opening windows.

There is more than one way to view the directory hierarchy, but the simplest is via the "My Computer" icon on the top left of the screen. Earlier we showed how to reach the third year area on Kaluta. Open this again now.

The folders indicate subdirectories. To open (or "change to" in Unix-speak) a subdirectory you just double click on it. Open the subdirectory with your user name (your "Home Directory" on Kaluta). You should then see the contents (if any) of your home directory. The way that the contents of a directory are shown can be changed using the "View" menu at the top of the window.

Lets now create some subdirectories. This is done by (clicking on the window background if necessary so that no folders or files are selected and) choosing [File|New|Folder]. This will add a new folder, and position the cursor so that you can name it. Make a directory for your laboratory work, say LABS. Now you can store all the files that you create for your laboratories in the subdirectory LABS and similarly for the other topics. If you select one of these and click on "File" you will see a range of other options relevant to the selected directory - you can rename it, delete it, and so on.

To show that these windows are just another way of looking at a file structure of the same type as Unix-based systems, we'll look at the same directory structure through a DOS window. Launch [Start|Programs|Command Prompt] to get a DOS window with a command prompt, similar to that used in an xterm under Linux. The prompt will contain the drive (or file system) name and the path to the current directory starting from your home directory. For example, in the home directory it might show:

 Z:\zzyp-z>

If you then give the command

 cd LABS

it will show

 Z:\zzyp-z\LABS>

Providing the machine is set up correctly, many of the basic Linux commands will work directly from DOS. For example, ls lists the contents of a directory, mkdir creates a new directory, cd <dir_name> is used to change to a directory, and cd .. is used to change back up to a directory's parent directory. For historical reasons, DOS also has its own commands --- for example dir instead of ls. There are also many other differences. For example, DOS uses a backslash instead of a forward slash between directory names, DOS is not case-sensitive, so LABS and labs are considered to be the same, and DOS file names cannot be longer than 8 characters followed by a 3 character extension (for example longestn.ame).

Traditionally single letter names followed by colons like A: and C: represented disk drives (A: is traditionally a floppy disk drive and C: a hard disk). Now that DOS has become NT and has become networked, remote filesytems are treated as "virtual" drives. The "Z:" above is an example, as we have mentioned this refers to an area on Kaluta. You can change to a different drive just by entering its name. For example:

 Z:\zzyp-z\DAT> C:

 C:\>


3.2 Editing Files

You will need to be able to create files and then edit the files that you have created in order to correct errors, add more material and so on. Like the Linux system, our NT system has several editors that you can use. These include:

It is also hoped that we will soon have a full Emacs editor available under NT, so that you will be able to use the same editor under both Linux and NT.

For programming use, such as will be required in this course, it is best to use a plain text editor, rather than a "wysiwyg" (what you see is what you get) typesetter. The latter, of which Wordpad is an example, are more appropriate for printed documents. They insert control characters to format the text, change the typeface, and so on. If your programs contain these they are unlikely to work correctly (and the bugs may be non-printing control characters, so you may not see them in your code!) The wysiwyg editors usually have an option for saving in text mode, but it is safer to simply use a text editor.

Notepad and Micro Emacs are examples of text editors. Notepad has a very simple, but somewhat limited, point-and-click interface. If you write Java files using Notepad, when you save them be sure to choose "All Files" and put the file name (eg "myfile.java") in double quotes, otherwise NT will automatically append ".txt" to the filename.

Micro Emacs is a little more comprehensive, although it is a poor second cousin of the full (Linux) version. While it is OK for editing simple programs, for serious programming work the full version of Emacs (note this link is to the CS220 web page) is recommended.


3.3 Manipulating Files

The text editors described in the previous section allow you to create text files in your home directory and any of the subdirectories that you have created. This is because you have been given write-permission (or "change permission") on the area of the file system assigned to you. You will not be able to create files in areas where you do not have write permission.

There are several commands that allow you to manipulate files. The simplest thing that you may want to do is to look at a file. If the file is of a suitable type, you can do this by highlighting the file's icon (for example via "My Computer") and choosing [File|Quick View].

Moving files and copying files is done in a similar way to the Macs you used in first year. To move a file from one directory to another, just open both directories, click on the file, and drag it to the new directory. To copy a file do the same action while holding down the Control key. To delete a file or directory, just select it and choose [File|Delete].

Finally you will occasionally want to print out a file in order to get a hard copy of it. Providing a printer has been installed, you can print a file by choosing [File|Print].


4. Getting Started with Java

Finally we know enough to get started with the Java compiler and interpreter. We shall just enter a simple program, compile it and run it.

Firstly create a subdirectory java either just for this exercise or more permanently for your Java code. Then open an MS-DOS window and change into that directory.

Now we will create a source code file that contains the Java source code for a simple program. All Java source files must have a name of the form file.java, where file is the name of a class declared in the file. Use an editor to create a file called Hello.java that contains the following code.

 public class Hello {
   public static void main(String[] args) {
     System.out.println("Not another Hello World program");
   }
 }

Next the source code must be compiled into byte code by the Java compiler javac. The command

 > javac Hello.java

will invoke the compiler. If you get an error message saying that javac is not recognised as a command, enter the command

 > path C:\share\NavGold\Program\java\bin

and try again. This tells MS-DOS where to look for the java executables. The compiler will create the file Hello.class which contains the byte code for this particular class (which in this case is the only class in the program). The byte code is then interpreted by the Java interpreter java.

 > java Hello
 Not another Hello World program

Notice that you must give the compiler the full name of the source code file (with the .java included) while you only give the interpreter the name of the class (omitting the .class).

4.1 Getting Java code using Netscape

One benefit of the hypertext exercise sheets is that you can obtain Java programs, or parts of programs, directly from the sheets through your browser. There are two ways in which programs may be provided.

If a program or part of a program appears on the sheet, you can simply copy and paste it into your text editor. Just select the text in the netscape window and choose [Edit|Copy]. Then select the text editor window and choose (in the case of Micro-Emacs; similar for other editors such as Notepad) [Edit|Clipboard|Paste]. Try it with the following Java program and make sure it works.

import java.util.Date;

public class DateTest {
  public static void main(String[] args) {
  Date todaysDate = new Date();
  System.out.println("Todays date is " + todaysDate.toLocaleString());
  }
}

Finally, instead of listing programs or parts of programs (particularly for larger programs) a link may be provided to the actual Java source file. For example, here is a link to the file DateTest.java which contains (almost) a copy of the above program. By following the link you should get a listing of the file. You can download a copy of the file to your disk by pressing and holding the right mouse button while over the link. Then from the menu that appears, select "Save Link As.." which will open a window for saving the file. Give the filename DateTest.java in your java directory (this will overwrite the previous copy).


Task: Download the file DateTest.java as described above. The program contains a deliberately inserted error. Compile it and find and eliminate the error.


© Kym MacNish, Gordon Royle 1997; modified (with permission) by Paul Hadingham.