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

Due: Thursday 9/13 at 8am

This homework will introduce you to our computer lab, some basic Unix commands, a text editor like Atom, Emacs, or vim, 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. Submitting your work is optional for this assignment.

  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 Atom or Emacs. 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. Optionally, submit your program Hello.java using the HW 0 submission page.
    HW 0 won't be graded, but submitting it will help me troubleshoot potential issues with our submission script. 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 want to work on your own computer

If you cannot login to the lab computers, or if you're adventurous, you can try to work on your own computer. This will likely involve installing the Java SDK and an editor. Note that we will only provide limited support for this option for now, and more detailed instructions will be added later. If you're up for it, try the following:
  1. On a Mac, open a terminal window; on a PC running Windows 8 or Windows 10, open the Powershell. Both will give you a Unix prompt or something very similar (though on Windows you'll have to type backslashes \ instead of forward slashes /).

  2. 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 4. If you get a higher number you will likely be fine as well.

  3. Download and install the JDK 8 from the Java SE Downloads page at http://www.oracle.com/technetwork/java/javase/downloads. Click the download button for "JDK" for Java SE 8. Follow the instructions there and all should be well. Open a new terminal window and repeat step 1 to check that it worked. On Windows, you will likely have to edit the path as well to add the folder where javac can be found, (something like C:\Program Files\Java\jdk1.8.0_181\bin ).

  4. Install a text editor, e.g., Atom, or on Windows Notepad++.

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

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

  7. Complete the lab (steps 6 and 7 above). Use the text editor you installed to edit the file. Note that you cannot access any of the files starting with ~schar/ since they reside on our server.