CS 101
Computer Science 1 in Java
Prof. Alvarez

Downloading and Installing the Software for this Course

Install the JDK 7 software on your computer by completing the steps described below (in the order shown) by the end of the first week of classes. You will not be able to start working on the programming homework assignments until you have finished this installation. Pay careful attention to the spelling of all names of variables, files, folders, etc., including punctuation and upper/lowercase distinctions. The instructions below assume that you will be working on a machine running Windows.

For Mac OS:

  1. Please note that most Macs with up-to-date software already provide the previous version, 1.6.X, of the JDK software. You can verify what version is on your Mac by opening a Terminal window (Applications:Utilities:Terminal) and typing javac -version (and then pressing enter) at the prompt. Version 1.6 or later is sufficient. You do not need version 1.7 (Java 7).
  2. For the latest Beta version of the JDK for Mac OS-X, see http://jdk7.java.net/macportpreview/.

For Linux: follow the JDK 7 Release link at http://jdk7.java.net/, and navigate to the appropriate version for your system.


Installing the JDK (Java Development Kit)

  1. Download the appropriate JDK 7 installation file for your system from the JDK 7 Release link at http://jdk7.java.net/ to the Desktop on your computer. For Windows, the file that you need to download is named jdk-7u2-windows-i586.exe. Linux and Solaris versions are also available through the JDK 7 Release link. For Mac OS-X, see http://jdk7.java.net/macportpreview/. Note that you will need the full JDK (Java Development Kit), not just the JRE (Java Runtime Environment). The JRE only allows you to run existing Java programs, but not to develop your own programs.

  2. Run the installer program by double clicking on the jdk-7u2-windows-i586.exe file icon on the Desktop. You will need to accept the licensing agreement in order to proceed with the installation. You should install at least the Java runtime environment, development tools, and Java plug-in for your web browser. Demos and source code are optional.

  3. Set the PATH and CLASSPATH environment variables by following the instructions below.

  4. Test the installation as described below.

  5. Not needed for the first week but recommended: download and install Eclipse as described at the bottom of this page.

  6. Mandatory: once you have completed the installation, share the good news on the CS1 site on BB Vista (cms.bc.edu), by submitting screenshots of the test programs running on your installation.


Setting the PATH and CLASSPATH environment variables

  1. In the Start Menu (normally near the lower left corner of your desktop) select Settings, then Control Panel (Open). This should display the Control Panel window on your screen.

  2. If an icon labeled System is visible in the Control Panel, double click it. Otherwise, select the Performance and Maintenance icon first; the System icon should then become visible in the window.

  3. Double click the System icon. Select the Advanced tab in the resulting System Properties window, and click on Environment Variables.

  4. In the list of System variables, select the variable named Path. Double click on the Path entry in the list, or select Path and click the Edit button. This will open a new "Edit System Variable" window; place the cursor at the very end of the "Variable value" field and append the text
    ;C:\Program Files\Java\jdk1.7.0\bin
    (exactly as shown, including the leading semicolon) at the end of the current value, then click OK. This instructs your computer to search in the above folder for the Java software tools when compiling and running Java programs. (If for some reason you installed Java in a folder other than ;C:\Program Files\Java\jdk1.7.0\bin on your machine, you will need to use the appropriate path name in this step - however, try the folder name given here first and redo this step only if the installation does not work initially).

  5. Setting the CLASSPATH variable

    In the Environment Variables window, click on "New". This opens a window titled "New System Variable"; type classpath in the Variable name field and .;C:\cs101 (note the leading period and semicolon) in the Variable value field, then click OK. This tells your computer where to look for Java class files when running programs - the period represents the current folder and C:\cs101 is the cs101 folder; if you placed your cs101 folder in a different location on your computer, use the appropriate full path (location) here instead.

  6. Click OK in the Environment Variables window, and then in the System Properties window.


Testing the JDK Installation

  1. First install the JDK and set the PATH environment variable as explained above.

  2. Create a work folder named cs101 in the C: drive on your computer. Do this by double clicking on the "My Computer" icon on the Desktop and selecting Create New Folder, then naming the new folder cs101.

  3. Download the file HelloWorld.java to your cs101 folder by selecting File -> Save Page As and navigating to the appropriate location on your file system. If given the option, save the file as type "All Files" rather than "Text Document" (otherwise the suffix ".txt" may automatically be added to the name of the file, which you don't want).

  4. Open a command window (Programs -> Accessories -> Command Window). Inside the window, type
    cd c:\cs101
    (and press enter). This should set the window to the cs101 folder.

  5. Type dir (and press enter) to see the contents of the cs101 folder. Make sure that HelloWorld.java sppears in the listing. If not, repeat the first two steps until it does. If the name of the file is slightly off, for example HelloWorld.java.txt, rename the file by moving it to one with the desired name HelloWorld.java. For example:
    move HelloWorld.java.txt HelloWorld.java

  6. In the command window, type
    javac HelloWorld.java
    (press enter). This runs the compiler on the HelloWorld.java source file. If compilation succeeds, there will now be an additional file named HelloWorld.class in the cs101 folder. If there isn't, or if you see any error messages as a result of attempting to compile, send me and the TA an e-mail immediately; your e-mail should include a step-by-step explanation of what steps you carried out and exactly what error messages appeared (and when). This will make it easier for us to help you out.

  7. Once you've successfully compiled HelloWorld.java and created HelloWorld.class, run the program by typing
    java HelloWorld
    (press enter). You should see the words "Hello, World!" in a window on the screen. If not, send us an e-mail as explained in the preceding step.

  8. Repeat the preceding steps for the program ScannerTest.java. When run, the ScannerTest program should prompt you to enter your age and should respond with a brief message in the command window itself (as opposed to a separate window like the HelloWorld program does).


Optional but recommended: Installing the Eclipse IDE (Integrated Development Environment)

  1. Download the Eclipse IDE for Java Developers zip file from http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigosr1.
  2. Uncompress the Eclipse IDE zip file using WinZip or your favorite file compression utility.
  3. Inside the uncompressed Eclipse folder, you'll find a folder named eclipse. Inside the eclipse folder, there should be a file named eclipse.exe. That is the executable file - the one that you'll need to double-click in order to run the Eclipse IDE.