The Windows Command Prompt is used in this course to compile (and download to robots) MaSH and Java programs. This tutorial covers aspects of the Windows Command Prompt which are required or beneficial to Java and MaSH development.
Aspects covered:
Go to Start -> Programs -> Accessories -> Windows Command Prompt
A window appears with some text in the top left corner, this is the command prompt.
The prompt may look like the following:
C:\>
The C:\ indicates the current drive and directory. The
> is always present.
dirListing the directory's contents is useful to confirm you are in the right directory, to check whether the file you are after is in the directory, and to check the exact spelling of a filename.
To list the contents of the current directory type dir at the
command prompt and press enter.
A listing of the current directory's contents will appear. If the command
prompt says C:\ then you will get a listing of all of the files
in the C:\ directory. If the command prompt says something like
H:\ or Z:\ (ie your home directory) then you will
get a listing of the files in those directories.

If your files are on a different drive to the one displayed in the command
prompt then you will need to change to that drive. For example, if the prompt
says C:\ but your files are on your home directory
(H: in Nathan and Logan, Z: on the Gold Coast) then
you will need to change to that drive first.
To change the drive type in the letter of the drive followed by a colon
and then enter. For example, to change to H: simply type
H: then enter.
Once you have changed drives list the directory contents to ensure you are on the correct drive.
cdYou should have directories in your home drive which you have created to organise the files for the different courses you are enrolled in. You will need to change to one of those directories to be able to access the files in those directories. If you don't have any directories on your home drive then create one for 1001ICT using Windows Explorer.
The Windows command for changing directories is cd followed
by the name of the directory to change into.
For example if your Programming 1 files are in a directory called
1001ict then to change into that directory you would need to type
cd 1001ict and press enter.
The prompt would now change to indicate that you are in the 1001ict
directory, eg:
H:\1001ict\>
List the directory contents of this directory to make sure you are in the right directory.
You may need to change directories again, for example in your 1001ict
directory you may have a directory for Java programs. If so, change
directories again by typing cd followed by the name of the
directory, eg. cd java
Typing commands can become laborious. Sometimes we repeat the same sequence of commands over and over again. For example we may compile a file, run it, find a bug, and compile and run it again. The Windows Command Prompt stores a history of the commands we have entered to save us retyping them. We scroll through the history by using the up and down arrow keys. The up arrow key moves backwards through the history.
For example, if I typed the following two lines:
H:\1001ict\java\> javac HelloWorld.java H:\1001ict\java\> java HelloWorld Hello World H:\1001ict\java\>
Pressing the up arrow would display java HelloWorld at the
command prompt and pressing the up arrow again would replace it with the
previous command javac HelloWorld.java. Try pressing the up and
down arrow keys to cycle through the commands you have entered in this
tutorial.
To further ease the tedium of typing commands, we have the file name completion feature.
Type a command, but don't finish typing the whole file name:
H:\1001ict\java\> javac Hel
Then press the tab key. The rest of the file name will be typed for you.
If it is the wrong file name, eg HelloWorld.class instead
of HelloWorld.java, then keep pressing the tab key until you get
the name that you want.
Getting to the right folder using cd can also be tedious. A
shortcut is to drag the icon for a file or folder from the Windows Explorer
onto the Command Prompt window. The full path of the file or folder will be
typed onto the command line for you.