CS 201 - Homework 0 - Unix and Java warm-up

Due: Wednesday 9/13 at 8am

This homework will introduce you to our computer lab, some basic Unix commands, a text editor like Emacs or Atom, and how to compile a simple "hello world" application in Java. Each student must complete this homework individually, but you can get as much help as you want, either from other students, or from the lab tutors. Check the course web site for tutor hours.

  1. Go to the MBH 632 lab and familiarize yourself with the Linux machines. Log in with your usual username and password. (If you cannot log in, see section below.) Once logged in, move the mouse in the upper-left corner to start applications. Two important ones are near the top of the list: "Terminal" and "Web browser". You can also find them in the "dock" at the bottom of the screen, or by right-clicking on the desktop. In the dock (or via Alt-F3) you get the "Application Finder", with which you can search for other applications such as Emacs or Atom. Spend some time exploring the interface, and try to figure out how to start a web browser and the file browswer. If confused, ask other students or the lab tutors.

  2. Go through the CS 201 Unix tutorial. This will teach you how to use basic Unix commands.

    Identify the function of and experiment with these Unix Commands:

    ls        cd        cp        mv        rm        mkdir     pwd
    man       history   cat       more      grep      head      tail
    
    Learn these commands -- you will use them often.

  3. (Optional) Go through the CS 201 Emacs tutorial. This will teach you how to edit files with Emacs.

    Identify the function of and experiment with these Emacs Commands:

    C-x C-s    C-x C-c    C-x C-f    C-x C-w    C-g    C-a    C-e
    C-d        C-_        C-v        M-v        C-s    C-r    M-%
    

    Note that we don't require you to use Emacs. You are welcome to use any editor you want, for instance Atom (which is also installed in the lab) or Sublime Text, which are more straightforward to learn. Later in the semester we will switch to Eclipse, an integrated development environment for editing and compiling code. However, as a computer scientist, it is very useful to know at least one editor that is purely text-based, and doesn't require a mouse, so you can modify files when you are logged into a server via SSH or Putty. Emacs is one popular choice; another is vi/vim. In both case you will need to learn all the control sequences, but it is worth it!

    (For some fun, survey the CS faculty what editors they use. Be prepared for some strong opinions. If you ask me, real programmers use emacs :)

  4. Make a directory cs201 in your Unix account for CS 201 work. Use the Unix command "chmod go-rwx cs201" to make this directory accessible only by you.

  5. Make a subdirectory hw0 in this new directory.

  6. As described in the Unix tutorial, copy the file ~schar/cs201/examples/hello/Hello.java into your hw0 directory, compile it, and run it. Then, edit it to add your name in a comment at the top, and change the program so it prints something different. Recompile, and run it again.

  7. Submit your program Hello.java using the HW 0 submission page.
    If you get an error when trying to submit, please send me an email and include the error message.
Congratulations! You are now ready to write and compile your own Java programs for this course.


If you cannot login to the lab computers

If you cannot login: If you cannot login to our lab computers yet, you can try to work on your own computer. More detailed instructions will be added later, but for now do the following (this assumes you have a Mac):
  1. Open a terminal window and type "javac -version" to see if you have java installed already. If it prints a version number starting with 1.7 or 1.8 you are all set, and can skip to step 3.

  2. Download and install the JDK from the Java SE Downloads page at http://www.oracle.com/technetwork/java/javase/downloads. Click the download button for "JDK". Follow the instructions there and all should be well. Open a new terminal window and repeat step 1 to check that it worked.

  3. Follow the lab instructions above to create a cs201/hw0/ folder from your Terminal.

  4. Save the file Hello.java in the folder you created.

  5. Complete the lab (steps 6 and 7 above). Note that you cannot access any of the files starting with ~schar/ since they reside on our server. Also, you'll have to install a text editor, e.g., Emacs, Atom or Sublime Text.