Compiling and Running a DoodlePad Program

Setting Up

Once you've written your program, make sure to save it to a file with a base name that matches your main class and the .java extension. For example, assume you have the program introduced in About DoodlePad:

import doodlepad.*;

public class MyFirstOval {
    public static void main(String[] args) {
      Oval oval1 = new Oval();

Save this program to a file named "". Make sure your program and the doodlepad.jar file are in the same directory by saving your program to a directory that already has a copy of doodlepad.jar, copying doodlepad.jar from another directory into your current one, or if necessary, download a new copy of doodlepad.jar.

Compile Your Program

Open a Command Prompt (on Windows) or a terminal (on MacOS or Linux) and change the current working directory to the one containing your program file and doodlepad.jar. Enter the following command to compile your program. If everything works as expected, you will have the file MyFirstOval.class in your directory. If you see any compiler errors, fix your mistakes and compile again. Repeat this process until you have no more compiler errors.

javac -cp doodlepad.jar

Run Your Program

To run your program, on Windows enter the following command into the Command Prompt. Note the semicolon (;).

java -cp .;doodlepad.jar MyFirstOval

On the Mac or Linux enter the following, slightly different command into the terminal. Note the colon (:).

java -cp .:doodlepad.jar MyFirstOval

After a moment you will see a new Pad graphics window with an Oval object displayed. In this case you may click and drag the Oval around the Pad window.

If you are using another development tool, like BlueJ and DrJava, follow instructions provided with those tools to compile and run your program.