Setting up your programming environment at home


In CS 117, CS 127, and some of our other courses, we use a combination of text editor and the command line java compiler, javac. You may use any text editor you like, but the official "supported" text editor for these classes is jEdit. You are free to install the proper tools on your own computer, but your programs MUST compile and run on the standard lab Linux setup.

The lab computers are already set up with all of the software that you will need to create, compile, and run your programs. The following is a brief tutorial for setting up a similar programming environment on your home computer.

Note that we cannot officially support any setups outside of the lab, although we will try to answer questions whenever possible.

Note that the current version of Java is Java 6.0 (also known as Java 1.6.0). This is the version that we have installed in the department labs. There is no difference between Java 5.0 and Java 6.0 whatsoever that impacts our courses (the differences are very obscure), so if you have Java 5.0 installed on our home computer, there is no need to upgrade. Java 6.0 has not been released for the Mac yet, so if you're using a Mac at home, you'll need to install Java 5.0. Regardless of what version you're running at home, you should always make to test your code on department computers before submitting.

Note that on the department machines, we have changed the default options for jEdit slightly. See the very bottom of this page for a list of the changes we have made to jEdit.

Linux
Windows
Mac

Linux

You will need to install jEdit (or, alternately, use your favorite text editor like emacs or vi) and the Java JDK. We will be using version J2SE 6.0 (also known as J2SE 1.6.0). Here is the link to the Downloads page: choose "JDK 6 Update X" (where X is the most recent update. It is important that you download the JDK (Java Development Kit), NOT the JRE (Java Runtime Environment)! (The JDK comes with the JRE; you will need the JDK to compile your programs.) Installation instructions are also linked on this page.

Make sure that you put the Java executables (javac and java) in your path. There are several ways to do this:

Assuming you have installed everything correctly, usage will be the same as it is for the lab computers.

Finally, once you have completed your work you will want to transfer it to your department account so that you can test it there before submitting. To do so, use the scp command:

scp [filename] [username]@prism.mathcs.carleton.edu:~

... and enter your Carleton password.

This connects to prism, which is one of our department computers, and copies your file to your home directory.

If you actually want to connect to prism remotely to run your code, do so by typing

ssh [username]@prism.mathcs.carleton.edu

... and enter your Carleton password. This will give you access as if you were sitting in front of a terminal window here in the department, but note that you will not have access to any kind of graphics or images.

Windows

You can use Notepad if you like to write your programs, though you will probably be happier in the long run if you install and use jEdit. If you do choose to use Notepad, make sure that you save your files as text, but not with an automatic extension; otherwise, your class files will most likely be written to a file that ends in .txt. Here is the link to the Downloads page: choose "JDK 6 Update X" (where X is the most recent update. It is important that you download the JDK (Java Development Kit), NOT the JRE (Java Runtime Environment)! (The JDK comes with the JRE; you will need the JDK to compile your programs.) Installation instructions are also linked on this page.

You will probably want to create a directory to store all of your Java programs, e.g. C:/JavaFiles.

To compile and run programs, open a Command Prompt window, and cd to the directory where your program file(s) live(s). Then type javac and/or java as described for the lab computers.

If you try to compile or run a Java program, and you get an error like NoClassDefFoundException or Can't find class, you may need to set your CLASSPATH environment variable (i.e., tell Java where to find your class files). This page explains how to set your classpath in Windows.

If you try to compile or run a Java program, and you get an error like javac: Command not found or java: Command not found, you need to set your execution path (PATH). To do so, go to Control Panel, select System, and find the button that says "environment variables". You should be able to find the PATH here and append the path to where Java is installed.

Finally, once you have completed your work you will want to transfer it to your department account so that you can test it there before submitting. To do so, use the program WinSCP. After you have installed the program, start it up, and enter prism.mathcs.carleton.edu for the host name, and enter your user name and password in the appropriate boxes. Click Login. Click Yes to trust the host (if this question appears). You should then see your local computer on the left side, and your home directory for our department accounts on the right side. Drag and drop your files and directory as appropriate to move them over.

If you actually want to connect to prism remotely to run your code, do so with the program PuTTY. When you start PuTTY, enter prism.mathcs.carleton.edu for the Host Name, and click Open. This will give you access as if you were sitting in front of a terminal window here in the department, but note that you will not have access to any kind of graphics or images.

Mac

You can use any text editor that you like to write your programs. We recommend, in particular, jEdit. If you use a different text editor, make sure that you do not automatically save your files with an extension, or else your programs might save with a .txt extension. Also, make sure that your files save as plain text and not RTF.

OS X has Java automatically installed, but you may or may not have Java 5.0: you might instead have an early version (such as Java 1.5). To check, open up the Terminal, and type java -version. If you see something regarding 1.5, you're fine. If you have an older version, you'll need to download the newest version of Java (J2SE 5.0) from this page. This doesn't replace the old version of Java, but adds Java 5.0 to your system. You'll then need to make sure that you're using the right version of Java as you work with your assignments. This is tricky to get right. Try this:

  1. Open up the Terminal.
  2. Make sure that you are logged in as administrator by typing

    sudo su root

    and entering your password if prompted.

  3. Change your directory by typing

    cd /System/Library/Frameworks/JavaVM.framework/Versions

  4. Type

    rm CurrentJDK

    to remove the shortcut to the old version of Java.

  5. Type

    ln -s 1.5.0 CurrentJDK

    to make a shortcut to the new version of Java.

  6. Close your terminal window.
  7. Open up a terminal and type

    java -version

    to confirm your version. You should see a version number like 1.5.0_xx (where xx is the latest release number).

To compile and run programs, open a Terminal window, and cd to the directory where your program file(s) live(s). Assuming you have installed everything correctly, usage will be the same as it is for the lab computers.

Finally, once you have completed your work you will want to transfer it to your department account so that you can test it there before submitting. To do so, use the scp command:

scp [filename] [username]@prism.mathcs.carleton.edu:~

... and enter your Carleton password.

This connects to prism, which is one of our department computers, and copies your file to your home directory.

If you actually want to connect to prism remotely to run your code, do so by typing

ssh [username]@prism.mathcs.carleton.edu

... and enter your Carleton password. This will give you access as if you were sitting in front of a terminal window here in the department, but note that you will not have access to any kind of graphics or images.

jEdit settings

We have made the following changes to the default settings for jEdit. You may wish to do the same if you are using jEdit on your computer.

  1. Utilities, Global Options, Editing: set tab width to 4, indent width to 4, check soft (emulated with spaces) tabs
  2. Utilities, Global options, Text Area: uncheck end of line markers