Lab 2 setup instructions
Downloading files and setting up a working directory
- Download the code for this lab into the directory you want to work in.
lab2.tar (Right-click -> Save Target As...)
- Extract the contents of the tar file. Find the file and double-click on it.
The file should open up automatically in WinZip.
- Click the Extract button. Then pick the directory to place the files
by typing it into the Extract to: textbox or browsing the file tree.
- Be sure that Use folder names is checked off.
- Then click the Extract button.
- Notice that a folder called lab2 is created. Inside this folder are
two items:
- ballworld.jar this contains the compiled ballworld code.
- java this contains the ballworld source code. you shouldn't need to
use this at all, but it is available for your reference.
- Your working directory is the lab2 directory.
Setting up DrJava
- Start DrJava
- Select Edit-->Preferences
- For Resource Locations-->Extra Classpath, click the Add button
and navigate and select the ballworld.jar
- For Miscellaneous-->Indent Level, change it to 4.
- For Miscellaneous-->Working Directory, select the lab2 directory
created by extracting the tar file.
- Click Apply and OK.
Running Ballworld
- Navigate to your lab2 directory and Right-click-->Open Command Window Here
If you don't have Open Command Window Here installed, then just open a
command window to the directory.
- At the prompt, type the following and hit Enter:
java -jar ballworld.BallWorldGUI
- BallWorld should start up. You can load the classes you write using the
File-->Load Ball...
Writing your first class
- DrJava starts off with an untitled file. Start off by typing in the beginning
of your first class, Dud. Do not specify any package names (contrary to the lab handout)!
- Save the file, be sure to save it in the lab2 folder.
- Hit Compile All to compile the code.
- When your class is done, load it into BallWorld using the File menu.
- The "fully qualified classname" is your classname prefaced by the package it is in. Since we're not using any packages, just type in the name of your class.