Lab 1

Goals:

Task A: Learn Some Elementary UNIX commands

  1. Log-on to the lab machine under Linux using the same user-name and password as last semester. (If the computer is running Windows, you may need to restart the computer.)

  2. Observe the KDE windows interface. In the Linux window, the "K" icon in the lower-left-hand corner of the screen acts similar to the "Start" button under Windows. Some other icons along the bottom of the screen will launch some useful applications:

Command

Example

Description

ls

ls

List the subdirectories and files in the current working directory

mkdir

mkdir cs2

Creates a new directory named "cs2"

cd

cd cs2

Change the current working directory to the subdirectory "cs2". Use "cd .." to go up one level in the directory tree.

emacs21

emacs21 Test.java

Invokes the emacs text-editor using the file called "Test.java"

less

less Test.java

Display the contents of the file "Test.java" on the screen

javac

javac Test.java

Invokes the java compiler on the Test.java file to create the Test.class byte-code file

java

java Test

Executes the Test byte-code file in the Java virtual machine

mv

mv src dest

Renames the file "src" to the file "dest"

cp

cp src dest

Creates a copy of the file "src" in a file called "dest"

ps

ps -a

Show all the processes that are running to find their process ID #'s, PIDs

kill

kill -9 123

Terminate the process with PID of 123

  1. If you have not already done so, create a subdirectory in your home directory called "cs2".

Task B: Using the emacs21 Text Editor

  1. In the shell window, change to the cs2 subdirectory.

  2. Invoke the emacs21 editor by typing "emacs21 Infinite.java" at the shell prompt

  3. In the emac21 window, type in the following Java program

    public class Infinite { 
       public static void main( String [] args) { 
          System.out.println("Start of main"); 
          while (true) { 
    
          } // end while 
       } // end main 
    } // end class Infinite 
  4. File | Save (current buffer) (or use the keyboard shortcut ctrl-x followed by ctrl-s)

  5. File | Exit Emacs (or use the keyboard shortcut ctrl-x followed by ctrl-c)

  6. Compile this code using the command: javac Infinite.java

  7. Run the code using the command: java Infinite

  8. Open another terminal shell and look at the processes executing by using the command: ps -a

  9. The processes labeled "java" are from your program (and the JVM) in the infinite loop

  10. You can kill the java program by clicking in the window where you started the program and typing ^c (<ctrl> key and the 'c' key at the same time)

  11. Do another "ps -a" command to see that the "java" processes do not exist any more.

(Alternatively, you could have issued a "kill -9 ###" command with the ### being the actual PID number of one of the "java" processes found by issuing the "ps -a" command.)

Task C: Downloading and unzipping from the course web-page

  1. Using the Konqueror browser, go the course web-page: http://www.cs.uni.edu/~fienup/cs062s06

  2. Click on the MemoPadApp.zip link and "Save to disk" in the cs2 subdirectory.

  3. In a shell window, change to the cs2 subdirectory.

  4. List the files in the directory and look for the file "memoPad.zip".

  5. Decompress the "memoPad.zip" file using the command "unzip memoPad.zip"

  6. Remove all the .class files by using the command "rm *.class"

  7. List the directory to see what files remain

  8. Compile the Java file containing the "main" method by "javac MemoPadApp.java"

  9. List the directory to see what files were created

  10. Run the memo pad application by "java MemoPadApp"

  11. (You may need to grab the lower-right hand corner of the frame and make it bigger to see the text in the textboxes that you type. Strange!)

  12. Examine the code in the MemoPad.java file

Task D: Get the description of Homework #1 and start it!