Lab Exercise #1
Wednesday, Sept. 8, 2004
You must complete this
laboratory in order to proceed with the course.
Objectives: The purpose of this lab is to give you some
practice
in organizing and manipulating your Unix file system, and to get ready
to use the program distribution that the course textbook provides. In
working
with Java beyond an introductory course, it is really important to
understand
directory structures, because Java compilers require a
correspondence
between your package/class structure and your directory structure.
Step 1: Make sure you have both GW and SEAS accounts.
You will need a SEAS computer account to do the work in this course. On
your lab PC, open an SSH window and log in to the SEAS server, hobbes.seas.gwu.edu. If you
can't log in, find out why and do whatever you must do so that you can
log in to hobbes.
Step 2: Bring your filesystem up to the CSci 53 state.
- If you took CSci 53 last spring,
you have two things to do in this step
- complete the survey form
that's in info/survey.txt.
- go to your csci53 directory and erase any *.class files that are left
there. This will free up some space. Don't erase your CSci 53 source
code, only the class files! Type
rm
*.class
- If you did not take CSci 53
last spring,
At the end of this step, you will have, in your home directory,
- a directory csci53
- a link (shortcut) csci53/programs53,
which points to the Lewis & Loftus programs
- a subdirectory, csci53/cs1,
which contains a Java source file Keyboard.java.
This Java class, written by Lewis & Loftus, is what we will often
use to get interactive input from the keyboard.
- a subdirectory, csci53/mbf, which contains some classes
written by Prof. Feldman.
- a few programs in csci53,
which you've copied and compiled just to get the feel of the compiler.
- any source files left over from CSci 53.
Step 3: Set up your CSci 133 directory structure.
There is no special setup script for this course, because it's
useful
for you to understand the details of your file system by setting up
some
of it yourself. This will help you learn to manipulate UNIX directories.
First modify your .kshrc file to let the Java compiler know
how
to find
all your Java files.
The .kshrc file (short for "Korn Shell startup file")
contains
commands that are executed each time you enter a copy of the shell --
when
you log in, when you call jcompile, etc. Move to your
top-level
directory, and bring .kshrc into your editor. It should
contain
the line . ~csjava/csci53.profile. Immediately below this
line,
add the line
export CLASSPATH=~:~/csci53:~/csci133:$CLASSPATH
which extends the path the compiler should take in looking for Java
sources and class files. In UNIX, the symbol ~ ("tilde") refers to the
home directory.
Now learn some useful variants of the Unix ls
command.
Move to your top-level directory, and type each of the following,
noting
down a description of what each one displays. Note that these are lower
case L's and not numeral 1's.
ls -a
ls -l
ls -al
ls -alR
ls -R
The last variant will be very useful in this lab. Each time this
handout
says "list your file system", use the last command above.
Now make a directory structure for the course.
In your top-level directory, type
mkdir csci133
Move into your csci133 directory, then type
ln -s ~csjava/programs133
which makes the program library visible to you.
ln
-s
../csci53/cs1
ln -s
../csci53/mbf
which lets you "see" the subdirectories of your csci53 directory.
Examine mbf/Screen.java with vi and note that the
first
actual
code line
reads package mbf;
Examine cs1/Keyboard.java
with vi and note that the first actual
code line
reads package cs1;
The
subdirectory structure matches the package structure.
Java
compilers REQUIRE this! In this course, whenever you copy a file from
the course distribution, you must put it into the equivalent location
in your own file
system, otherwise you will surely get compilation errors!
Now copy 2 files from the distribution into your own
structure.
Type
cp programs133/Smiley.java .
cp
programs133/ShowInputLoop.java .
Now compile and run two applications that use the class
files:
Type
jcompile
ShowInputLoop.java
jrun
ShowInputLoop
jcompile Smiley.java
jrun Smiley
Now read the two applications, and the documentation for
the two classes, carefully. You'll be using them.
Congratulate yourself on getting through all this!
(end of lab)