The command prompt is a way of running programs using text commands rather than mouse clicks. Back in the day, all computers worked this way, and the command prompt is all that remains (for a user) of these old fashioned operating systems (because of this it is sometimes called the "DOS prompt"). However, it is still useful for developers, because it shows you explicitly what is otherwise going on behind a mouse click, and, more importantly, allows for the JDK software to send us useful text messages.
Where is it?
On Windows 7, search 'apps' for 'Command Prompt'.
On other Windows, click on the Windows button at the bottom of the screen, then click on 'All programs' and, when the menu pops up, click on 'Accessories'. When the next menu pops up, Command Prompt should be on it.
Click on the Windows button at the bottom of the screen (or right-click on left end of task-bar in Windows 7 desktop). Click on 'Run...'. Type 'cmd' into the box, and hit 'OK'. If the 'Run' option isn't there, type 'cmd' into the 'Search Programs and Files' box. Don't type "command" - this will give you something that looks the same, but isn't on some Windows versions.
When you open it by either method, it will probably look something like this...
The c:\> bit is where you type. It shows you where you are in the directory structure. For the command prompt shown in the diagram, the user is on the c: drive and not yet in any directories.
After you have typed a command, you need to push the Enter (or Return) key on your keyboard to make the command work.
Four important features of the Command Prompt:
Navigating at the prompt
To move to a different harddrive, for example your D drive (if you have one), type:
And push the enter key. Your prompt should now say something like
Because the command line is text based, we need a text-based way of describing directories if we want to navigate them. We have a shorthand for writing directory structures that uses backslashes (or sometimes forward-slashes, depending on the software). A list of directories is sometimes called a Path. Using this path notation, a path that looks like this in Windows Explorer:
Would look something like this...
Note that if any of the directories in the path contains spaces, as "Assessment 1" does above, for some software you may need to put the whole path in double quotes to get it to work (try it without first):
The above is what is known as an "absolute address" - it tells you where something is without reference to where you are. It is worth also knowing that in this notation you can also give "relative addresses" for directories and files - relative to the directory you are in:
'\' or '/' is the 'root' directory of the drive you are on, that is, the lowest directory in the hierarchy (furthest left).
'.' is the current directory - i.e. the directory you are in.
'..\' or '../' is the directory below the current directory.
So, for example, ..\..\GIS means a directory that can be found by going to the directory two below the current one, then up into a 'GIS' directory (as you might if you were trying to get to the GIS directory from the 'Assessment 1' directory, above).
The DOS prompt command to move to a directory is cd ("change directory"). So, for example:
cd "Assessment 1"
To see what is in a directory, type
There are other commands, which you can see by typing Help, but you are unlikely to need any for the moment. File renaming, deleting, etc. is best done through Windows Explorer.
Push the Up-arrow and Down-arrow keys on your keyboard to cycle through previously used commands. You can then edit the commands using the Left-arrow and Right-arrow keys to move the cursor in the text and the Delete key to delete, with other keys to add. Note that if new typing starts to write over typing in front of it, press the Insert key on your keyboard to turn off this behaviour.
Cut and Paste
Note that the standard cut and paste keys don't work within the command prompt. To paste, right-click on the prompt with your mouse and choose Paste.
Resizing the Command Prompt window
When you're coding, chances are the command prompt window won't be large enough. The messages the JDK can send you can be quite extensive, and the 'buffer' (the amount of lines the prompt can hold) is quite small by default.
To resize the command prompt window, right-click anywhere on the border at the top of the window, and choose 'Properties'. Under the 'Layout' tab you should see options to increase both the screen size and buffer. A good setting for the buffer is width:130, height:400, and for the window size width:130, height:31. You can also check the font and colours under the other tabs. The system should remember your preferences next time you open the prompt.
When you're ok with this lot, head back using your browser's back button.