CS401 - Intermediate Programming Using JAVA (Recitation)

 

Lab3 - Some Tools and Submission Information


Introduction

Throughout this course there are a number of tools that will be necessary to help you write and submit your labs and assignments. In this lab you will learn to use a few of these tools, including:

1. Logging in remotely to access your Pitt files so you can work on your projects at home or in any computing lab on campus.
2. Submitting files to your submission directories so that you can submit your programming assignments correctly.
3. Copying a file from one computer to another using FTP. This will allow you to download files from your Pitt account to your own computer or other computer on campus (and vice versa).

 


Starting Up

Before starting this lab, log into one of the Sun Workstations in the Java Lab and open a terminal window. If you forget how to do this, refer to Lab 1.



Logging In Remotely to access your Pitt files

The Unix operating system allows users to log into machines remotely, so that you can access them from anywhere on the Internet. However, as a security measure, the Sun Workstations in the Java Lab only allow remote logins using secure measures (i.e. using encryption). This prevents snoopers on the network from capturing ids and passwords from unsuspecting users. Secure remote login from one Unix machine to another can be done on the command line using the command

ssh javalab.cs.pitt.edu

Try the command above from the terminal window of your workstation. The first time you do it from a given machine it may ask you about the key being used -- if so just type yes to continue with the login. Enter your password when asked (it assumes your id is the same one used in your original login) and note that you will then be connected to another Sun Workstation in the Java Lab. In case your prompt does not identify the machine you are using, you can find out about it with the command

hostname

To terminate your remote login session, type

exit

at the prompt. Your terminal window should once again be the workstation that is in front of you -- type hostname again to confirm this.

If you are using your own PC or a Lab PC somewhere else on campus, in order to remotely log into one of the Sun Workstations you must use a secure login program such as F-Secure or Putty. For information on using these programs to log into the Sun Workstations, check out the Web links indicated. Also feel free to see me for help during office hours.

If you do not have a secure login program installed on the PC you are using, you will not be able to remotely log into the Sun Workstations directly. However, you CAN log into the Pitt Unixs machines, which allow access to your same directories and also have the JDK installed (however, it is version 1.4, so some features we discuss in class may not work on Unixs). You can do this through the (non-secure -- your password is sent over the internet as clear text) telnet program, which is installed on every PC by default. There are various ways to invoke the telnet program on your PC. One way is explained below. The next time you are on a PC that is connected to the internet, try the following

Start Internet Explorer
>From the File menu, select Open, and type the following in the dialog box:
telnet://unixs.cis.pitt.edu
<You should now see a window with a login prompt>
At the prompt, type your id, then (when prompted) your password
Confirm that you are on one of the unixs machines by typing hostname
Confirm that you have access to your files by typing ls
Confirm that Java is installed on the unixs machines by typing java -version
Verify that you can compile and run Java programs by changing to the directory in which you stored your programs from Lab 1, then compile and run them. Also practice editing your .java files -- pico should work from this remote login just as it works on your terminal window.

When you are finished using your remote login session, make sure to log out by typing exit at the prompt.

Important note: If you log in remotely to Unixs using the techniques described above, you cannot execute any graphical applications. This is because graphical applications require a console window to display the graphics. Thus you must run graphical programs directly from a PC or from a Sun Workstation console.



Copying a file from one computer to another using FTP

Note: This part of the Lab should be done from a PC that is connected to the Internet -- either your own or one in a Pitt PC Lab.

At times you may want to copy files from your Pitt account to a Lab PC or to your own PC or vice versa. For example, you may be working on a program on your own PC in your dorm, but you want to copy it to your Pitt account so that you can work on it in the Sun Workstation lab (or to back it up). This can be done easily as long as your PC is connected to the Internet (Lab PCs are always connected, but your own PC may or may not be connected).

Using the same rationale explained above for remote logins, it is recommended that file transfer be done only using secure programs such as F-Secure or WS_FTP Home. However, if you don't have one of these programs you can still transfer your files using regular FTP from Internet Explorer. Try the following:

Start Internet Explorer
>From the File menu, select Open, and type the following in the dialog box:
ftp://ftp.pitt.edu
<You should now see some folders and some files in your IE window>
From the File menu, select the Login As: option
<You should see a dialog box with fields for your User name and Password, as well as some checkboxes>
Enter your Pitt Id and Password in the appropriate fields in the dialog box. Make sure that the checkboxes at the bottom of the dialog box are NOT checked. Then click LogOn.

The files in your home directory should now appear in your browser window. At this point you can transfer files using the normal Windows technique of "drag and drop". Simply open a window for the desired directory on the PC (ex: the C: directory, a floppy drive, a Zip drive, a Flash drive) and drag files as desired either way from one window to the other.

BE CAREFUL when transferring files that you transfer in the right direction. For example, if your most recent update was on your PC and you want to copy your files to your Pitt account, drag from your local PC window to the FTP window. Do it the opposite way if your most recent update was on your Pitt account files.

When you are finished with your file copying, close your Internet Explorer window to terminate the connection.



Updating your PATH to use JDK 1.5

As was mentioned in Lab 1, there are different versions of the Java compiler. Our text uses Java 5.0 (or 1.5), the most recent version. However, this version is not the default version used on the Sun Workstations. The binaries for Java 5.0 are stored in a directory that is not automatically searched when your unix commands are executed, so in order to use them you have to type the full path of each program (see Lab 1 section Java Versions for a reminder about this).

However, you can update your PATH variable so that the Java 5.0 path will be searched before the older version. This will allow you to compile and run Java 5.0 programs without having to type the entire path in. I have written a small script program that you can execute after logging in to do this for you. My script assumes that you are using the "bash" shell on Unix. This is the shell that most students have, but you need to check to make sure. >From a Sun terminal window type the following:

finger <yourid>

where <yourid> is your login name.

You should see some information about yourself including

Shell: /bin/bash

The instructions below assume that /bin/bash is your shell. If you see a different value for Shell, ask your TA or me and we can get a different script for you.

Make sure you are in your home directory. If you are unsure, just type

cd

and the system will automatically put you back into your home directory.

Copy the script makeit5 into your home directory from my Course Documents | Labs directory.

Take a look at the (one line) script by typing

cat makeit5

Note that all the script does is prepend an additional directory (the one containing JDK 1.5) to your old PATH variable

Now, for any new terminal window on your Sun (whether on the console or via remote log in), before compiling and running your Java programs, type the following:

source makeit5

Test that this works in the following way:

1. Log out of your workstation
2. Log back into your workstation
3. In a terminal window, type java -version
4. Execute your script with source makeit5
5. Type java -version again

You should notice that in Step 3 the Java version is 1.4 while in Step 5 it is 1.5. If this is NOT the case for you, see your TA to find out what needs to be fixed. Version 1.4 of Java will suffice most of the times but it will be necessary to run version 1.5 (e.g., Turtle Graphics).