Stand Alone Java in Windows (all)

Why use Stand Alone Java?

Setting up Stand Alone Java on your Windows personal computer is a very powerful way to edit your code. It has the following advantages:

  • Like remote login, you don't have to go to the SunLab to work. Score one for laziness!
  • Unlike remote login, there is no lag or delay when working with heavy graphics. Later in the course, you'll find remote login doesn't work so well for Cartoon, Swarm, or Tetris, and in fact may not work at all for final projects!
  • You don't need to be connected to deparment servers work. Show your dedication by working from your isolated cabin in the wilderness...or, more importantly, show your friends and family your work.

Of course, nothing in life is free. So there are a few downsides:

  • The installation process is kind of complicated. This page gives step-by-step instructions, but this is not reccomended for the faint of heart.
  • Unlike working in the SunLab or via Remote Access, you are compiling your code on Windows and not Linux. Remember: all work submitted must run correctly from Linux locally. It is strongly reccomended that you test your code in the SunLab before you turn it in. Programs that work on one OS do not always work exactly the same on another, despite what the Java developers want you to belive.

Installation & Setup Instructions

  1. Download Java

    You'll need the Java Software Development Kit (SDK) version 1.5.0 (This is also often refered to as Java 5) on your home computer. The SDK provides a java compiler as well as a virtual machine to execute your code. This is not the most current version, but it is what we run right now in the department.  It is up to you to decide which one you want. If you want to be as sure as possible that your code will run, then get the 1.5.0 version. Keep in mind, this is not the same thing as the Java Runtime Environment (JRE), which is installed on most Windows computer by default.

    You want to download the JDK 5.0 Update 8.

    Download the JDK

    There is also an option here to also download NetBeans, which is an IDE - a program where you can write, run, and debug Java programs. So you make those choices and agree to some things and you'll eventually get the file you need.

  2. Step 2: Install Java

    Now that you have the installation program on your computer, you need to run this program to install the SDK. Note: this will also install JRE 5.0 Update 8.

  3. Install Support Code

    Common support packages are what let your code at home work on the Sunlab machines as well. To install the support code, do the following:

    1. Make a course directory

      Make a convenient directory to store your work in CS15 on your home computer. We suggest a directory structure similar to what you have on the CS department. Create a directory on your C:\ (C: drive) called "course". You can do this by running "explorer" from your start menu, opening "My Computer", then opening the "(C:)" icon. In the window for the C:\ , select the "File" menu and select "New" and then "Folder". This will give you a new folder which you should rename to "course". Follow similar procedures to create c:\course\cs015, c:\course\cs015\bin and c:\course\cs015\lib directories. For each project you work on, you can create a subdirectory of c:\course\cs015 to work in.

    2. Download files:

      You should be ready to start downloading these packages by clicking on them in your web browser. Download them directly to the c:\course\cs015\lib directory. It is reccomended to download both, since you will need both at more than one point during the class.

      Do not unzip the wheels.jar or cs015.jar files that you downloaded and installed; Java can use them as libraries as they are now.

  4. Set environment variables (CLASSPATH and PATH)

    You can get by without this, but you'll definitely want to set the CLASSPATH and PATH variables. CLASSPATH tells Java where your projects and your support code will be. PATH tells Windows where to find the Java executables, such as java.exe and javac.exe.

    To set an environment variable:

    1. Right-click on "My Computer" and choose "Properies".
    2. Click on the "Advanced" Tab.
    3. Click on "Environment Variables".
    Windows System Properties

    The current system environment varibles are listed in the second box.

    Windows Environment Variables

    If the variable CLASSPATH doesn't exist, create it by clicking "New" and setting the value to the following. If it exists already, click "Edit" and append the following: .;..\;c:\course\cs015\lib\wheels.jar;c:\course\cs015\lib\cs015.jar;c:\course\cs015 (The dot at the beginning tells it to include the current directory) If for some reason, you are using other support package jar files, make sure you include those in a similar fashion

    Set the Classpath Environment Variable

    Setting the PATH variable is similar. Unless your system is set up oddly, the PATH variable should already exist. For a standard Java installation, you need to append the following to the path (again, semicolons are the seperator): c:\program files\java\jdk1.5.0_08\bin

    Set the Path Envrionment Variable

    Check to make sure this path really exists! If it doesn't, you may have a differnt version of Java and/or Java was installed in a non-standard location. In this case, either locate the bin directory and use that path or install the right version of Java (SDK 5.0 Update 8).

    Note:If you had some form of Java installed already, the PATH may contain a reference to another Java installation directory. You may want to delete the reference to this from the path to avoid confusion. For example "c:\program files\java\jre.1.5.0_05" could be deleted from the PATH since it references a JRE prior to the one installed with the SDK.

  5. Test it out!

    Provided you have installed Java properly and set up your PATH and your CLASSPATH as above, you should be able to compile your Java programs as you would in the Sunlab. Congratulations!

How to Work From Home

Overview

Working on a project involves setting up the provided code for the project, editing them on your computer, compiling them on your computer, running on your computer, moving your project to the Sunlab machines and handing in in the CS department.

Note: On the Sunlab machines (Linux), the forward slash (" / ") is used to separate directories when writing paths. On Windows, a back slash (" \ ") is used. This is important!! You must use the back slash in order for Windows to understand what you're trying to tell it to do.

Getting Support Code

Support code (more like stencils) will be available for the assignments once they are out. Your best bet is to run cs015_install <project> remotely or from the lab, download the appropriate files to your home computer (using one of the methods below). Put them in a project directory in c:\course\cs015\<projectName>\ , where you will be working on your code.

Editing Your Code

You'll need a good text editor, like Emacs, for editing your Java text files at home. You won't be able to use the same Emacs as available on the Sunlab machines, though there is a Windows version here. Another recommended editor is EditPlus. You can get a trial version from here. Also, you could try TextPad, which you can get here. I personally use Crimson Editor, available for free from here. Finally, you can use an IDE like NetBeans or Eclipse. Actually You can use any text editor you wish, even Windows' Notepad.

NOTE: Be aware that Windows and UNIX use slightly different formats for specifying line-endings. This can cause funny looking characters when you look at your code on the other system. The better text editors/IDE's understand this and convert between them seamlessly, but be on the lookout for this problem.

Compiling Your Code

Start up a command shell (similar to a UNIX shell) by clicking the "Start" menu and selecting "Run". If you're running Windows 95/98, type in "command"; if you're running Windows XP/2000/NT, type in "cmd". Press Return. Navigating the DOS shell is similar to navigating the UNIX shell. The one exception is navigating between different drives (don't worry about it if you don't understand). If your prompt does not say contain a "C:" then you are on a drive other than C drive and should type "C:" to get to it. Entering in "cd \" will then take you to the "root" directory of a drive. Now go to your project directory by typing "cd course\cs015\projectName". You can tell the contents of a directory by typing "dir" or "dir /w", adding a " /p" to the end of a dir command will make it pause at each page of output. You should be able to type "javac *.java" when you are in your project directory. Unfortunately for DOS shells, it's difficult to review more than one page of output, so you'll end up seeing the last few errors if there are many. In XP/2K, you can control the size and amount you can scroll back by right-clicking the title bar and choosing properties. Go to the Layout tab and make it bigger, if you so please.

Running Your Code

Once you've successfully compiled your code, you can run it using "java" if you wrote using a mainline. You do it like in Linux: java Tetris.App.

Handing in on Linux

Move your code to the CS filesystem (next section), and you can perform and electronic handin. Before you do this, you should go to the Sunlab or Remote Login and recompile and rerun your code on the Linux machines to ensure it still works. Allow enough time to do this! You can then follow the normal directions on handing in a project.

Moving Your Code to and from the Sunlab

There are a number of ways to move files to and from the Sunlab machinlab machiness. The following table summerizes:

MethodSetup DifficultyConvienience
EmailUltra-simpleAnnoying
VPNVery ComplicatedExtremely Handy
SFTP/SCPComplicatedVery Handy
FTPVery ComplicatedModerate

Now, the details:

Email the code

Yep, this is probably the easiest and least technical solution. But if you'd like more technical and convenient solutions, read on...

Setup VPN

This isn't terribly hard to do and it's really convenient. For setup information, check out the CS Department's VPN page. In particular, look under the sections "Setting Up" and "Windows Configuration." Be sure to follow the three links under the latter section - they provide important information.

SFTP/SCP

SFTP/SCP is a newer and more secure way to transfer files. It was created to replace FTP, which you may or not be familiar with. It uses the Secure Shell (SSH) protocol to secure the transfer. As a result, the process for setting up SFTP/SCP is very similar to setting up Remote Login with SSH. If you already have this set up, configuring SFTP/SCP is a breeze.

First, set up Remote Login. Follow the official department instructions. Obviously, if you've set up Remote Login already, go on to the next step.

Download a SFTP/SCP client. This tutorial will cover WinSCP, avaiable from CIS here.

Once you have downloaded and installed WinSCP, launch WinSCP. You should get a "Session" dialog box. Under "Host Name," enter ssh.cs.brown.edu. Leave the port number as 22. For "User Name" use your CS logon. Leave "Password" blank. The important part is the "Private Key File." This is the Private Key you created in the Remote Login setup process (using puttygen). Browse to your key file and select it.

WinSCP setup screen

Now click "Save" so it remembers your credentials. You should now see an option for your saved login under "Saved Sessions." Go ahead and logon. You should be asked to enter your passphrase. After that, you should be succesfully logged on.

By default, WinSCP operates in a two-panel mode, with local files on the left and remote files on the right. This the common setup of many file transfer applications, so it may be familiar. By default, the remote directory will be your Linux home directory. Navigating around the directory structure is pretty self-explanatory. To transfer files, drag them from one pane to the other.

FTP

I haven't tried this method, so I can't say too much about it. To be honest, FTP is just an inferior version of SFTP/SCP, and seems to be more of a pain to set up. But in the interests of flexibility, the steps are below.

Use "FTP" by opening a DOS shell (like above), going to the directory where you want to download or upload files, and typing "ftp in.cs.brown.edu". This will start a program that allows you to enter your login name. Enter your login name and get the Skey challenge. For instructions on Skey, try looking here. Use the challenge and your secret password with the Skey program to log in. You should be able to navigate the directory structure with limited shell commands such as "ls" and "cd". Within FTP, go to your ~/course/cs015/<projectName> directory. If you just logged in it should be cd course/cs015/<projectName>. To move files from your computer to the Sunlab machines, type mput *.java. You'll need to respond to FTP's questions with a "y" or "n" and pressing Return. To move files from the Sunlab machines to your computer, use mget *.java.

If you have questions: please post to the mailing list.