Introduction to Computer Science I

Tools


To set up your computer to do Java programming, find the section below for your type of computer, and follow the instructions.


Mac

Download Aquamacs: This program is an implementation of Emacs made for the Mac (using the Mac interface, Aqua). Begin by downloading it from the Aquamacs home page. Once you have, open the downloaded file to install the software. When you have completed following the directions, Aquamacs will be in your Applications folder, and you can open it with the Finder.

Download JDK: You also need the Java Developers Kit in order to use the java and javac commands on your own computer. Go to the JDK 8 download page. There, you will see, a section labeled, Java SE Development Kit 8u201. Underneath that section header, click Accept Licence Agreement. Then click on the link, jdk-8u201-macosx-x64.dmg. When this file has downloaded, open it and perform the installation. You will not find Java in your Applications folder; you will run it with commands at a shell prompt, about which more will be said below.

Open a terminal window: In your Applications folder is another folder, Utilities. Within that folder, you will find the Terminal app. Open it, and within it you will see a shell prompt, very much like the one for remus/romulus. You will be in your home directory on your own machine.

Copy your old work: At your shell, use the scp (secure copy) command to copy your work from remus/romulus. (If you have no work on those servers, then skip this step.) To copy your lab-1 directory, for example, do the following

  $ scp -r sfkaplan@remus.amherst.edu:lab-1 .
    

IMPORTANT: First, be sure to replace sfkaplan in the above example with your own username. Second, be sure to include the space followed by the period (.) at the end of this command; you will see an error if you forget that period.

You will be prompted to enter your college password. When you do so, your entire lab-1 directory will be copied into your own home directory. Repeat this command for lab-2 and, if you've created them on remus/romulus, lab-3 and/or project-1.

View source code in Aquamacs: From your dock, open the Finder. Then open your home directory via the Go menu (at the top of the screen), selecting Home. You should see the various directories/folders that you just downloaded. Try opening lab-2 to see the files inside. If you then open one of the source code files -- let's say LeapYear.java -- then the file will open in Aquamacs. You can then view and/or edit the file.

Compile and run something: Sticking with the LeapYear program as an example, try to compile and run it. The commands from remus/romulus work on your shell in your terminal window:

      $ cd lab-2
      $ javac LeapYear.java
      $ java LeapYear
      Enter a year: ...
    

Going forward: From now on, you can create directories and move around files just as you normally do within Finder. If you create a folder for each lab/project in your home directory, then you can easily change into those directories at your shell prompt (with the cd) command. Otherwise, do all of your editing in Aquamacs, and all of your compiling and running at the Terminal command line.

Submitting work: The cssubmit comand does not work from your computer. Instead, you should use your browser to visit the CS submission system, where you can submit your work via the web interface.


Windows

Download Emacs: The implementation of Emacs made for Windows is called Emacs-w64. Download it from the course web page. (Note that the real home page for this software has its own download link, but it is contained in a compressed archive format that would require separate software to access. I have repackaged it in a standard zip file.) Once you have downloaded this file, open it. Drag the emacs folder onto your Desktop.

On the Desktop, open the emacs folder. Within it is a folder named bin, which you should then open. Within this subfolder is a file named runemacs. Make shortcut for this file (right click on it, then select Create shortcut, which will then appear as a file named runemacs - Shortcut); drag the shortcut onto your Desktop. This icon is what you should double-click to run Emacs.

Download JDK: You also need the Java Developers Kit in order to use the java and javac commands on your own computer. Go to the JDK 8 download page. There, you will see, a section labeled, Java SE Development Kit 8u201. Underneath that section header, click Accept Licence Agreement. Then click on the link, jdk-8u201-windows-x64.dmg (at the bottom, next to Windows x64). When this file has downloaded, open it and perform the installation. You will run Java with commands at the command prompt, about which more will be said below.

Configure the command prompt: Click on the Start menu (the Windows icon in the lower left of the screen), and then type Command Prompt. You will see an icon for this program appear. Right-click on that icon, and then select Run as administrator. When asked for permission, click Yes. When the command prompt appears, enter the following two commands exactly as they appear:

      > setx JAVA_HOME -m "C:\Program Files\Java\jdk1.8.0_201"
      > setx PATH -m "C:\Program Files\Java\jdk1.8.0_201\bin;%PATH%"
    

Each command should yield the message, SUCCESS: Specified value was saved. You should now close this command prompt window.

Open a command prompt: Once again, click on the Start menu, and type Command Prompt. This time, just click on the icon to open the command prompt window. At the prompt, you can try the following command, which should yield the line of output shown, to test if Java is installed and the command prompt correctly configured:

      > javac -version
      javac 1.8.0_201
    

Copy your old work: At your prompt, use the scp (secure copy) command to copy your work from remus/romulus. (If you have no work on those servers, then skip this step.) To copy your lab-1 directory, for example, do the following

      > scp -r sfkaplan@remus.amherst.edu:lab-1 .
    

IMPORTANT: First, be sure to replace sfkaplan in the above example with your own username. Second, be sure to include the space followed by the period (.) at the end of this command; you will see an error if you forget that period.

You will be prompted to enter your college password. When you do so, your entire lab-1 directory will be copied into your own home directory. Repeat this command for lab-2 and, if you've created them on remus/romulus, lab-3 and/or project-1.

View source code in Emacs: If it isn't already open, double-click on the Desktop shortcut to runemacs that you created, thus opening Emacs-w64. From within it, select the File menu, and then Open file.... When the open-file dialog appears, you will need to navigate to the folder that contains your work. At the top of the dialog, labeled Look in:, clicking on the directory name that follows (likely, bin) will drop down a menu of possible folders. One of them has your name on it (e.g., mine reads Scott Kaplan), and is your home directory on your computer. Select that one. Within it you should see the folders that you copied from remus/romulus.

If we want (as an example or first attempt) to work with the lab-2 LeapYear program, then open the lab-2 folder and select LeapYear.java. You will see the code for that program. You need not change it, since this is just an example, but you are welcome to do so and save those changes, just for the sake of experimentation.

Compile and run something: Sticking with the LeapYear program as an example, try to compile and run it. The commands from remus/romulus are similar to the ones you should use at your command prompt:

      > cd lab-2
      > javac LeapYear.java
      > java LeapYear
      Enter a year: ...
    

Going forward: From now on, you can create directories and move around files just as you normally do within File Explorer. If you create a folder for each lab/project in your home directory, then you can easily change into those directories at your command prompt (with the cd) command. Otherwise, do all of your editing in Emacs-w64, and all of your compiling and running at the command prompt.

Submitting work: The cssubmit comand does not work from your computer. Instead, you should use your browser to visit the CS submission system, where you can submit your work via the web interface.


Scott F. Kaplan