Testing Code On Leland Machines

<< Back to JavaTools

NOTE: This document is meant to be a quick and dirty guide to get your code compiling and executing on the Unix machines. If these instructions do not work, please email cs108staff@gmail.com with your problem, and then refer to the More Detailed Unix Guide to try and solve your problem.

0. Machines That Work

You will only be able to compile and execute code on the following machines: IMPORTANT: Please make sure you are only using Java 5 features. To ensure this, only refer to the javadoc pages linked to by the CS108 website.

1. Setup your .cshrc File

Add the following to the end of your ~/.cshrc file:

# Java env variables
set path=($site_path /usr/class/cs108/bin . ~/bin)

# Set the class path for cs108 java files
setenv CLASSPATH .:/usr/class/cs108/jar/junit.jar

Then execute the following line to reload your ~/.cshrc file

source ~/.cshrc

Execute the following to ensure your path is set:

printenv CLASSPATH

It should say:

.:/usr/class/cs108/jar/junit.jar

2. Compiling Your Code

To compile all of your files, execute:

javac -g *.java

3. Running Your Code

If you want to run a class with a main function:

# Note that we do not include the ".class" extension
java <class name>

E.g., if I have a class called Tetris.class, that contains my main() function, then I would execute:

java Tetris

If you want to run a JUnit test with the Swing Graphical User Interface (remember, don't include the ".class" extension):

java junit.swingui.TestRunner <test class>

If you want to run a test in text-only console mode:

java junit.textui.TestRunner <test class>



Email problems with these instructions to cs108staff@gmail.com