Structured Programming   «Prev  Next»
Lesson 3Working from the command prompt
ObjectiveUse a command prompt window.

Working from the Command Prompt in Java

Throughout the course you will be interacting with your operating system from a command prompt window. From this window you will issue commands to navigate your computer's file system and to compile and run Java programs. It is quite possible that you are already familiar with using a command prompt window. If you are comfortable creating new directories and changing your current directory, you can jump right to the exercise for this lesson; however, if you are new to using a command prompt window you are encouraged to take a look at the following primer.

Command prompt in Windows 10

To open a Command Prompt window go to the Start menu, select Programs, and then select the MS-DOS Prompt application (Windows 10) or Command Prompt application (Windows NT/2000).
Screen shot of Start->Programs->Command Prompt
Screen shot of Start->Programs->Command Prompt

Screen shot of
Start->Programs->Command Prompt

Here is what the application looks like when it starts.
Screen shot of Command Prompt window
Screen shot of Command Prompt window
Note that the prompt displays the current directory. In this example it is C:\WINNT.
For navigating your file system from the Command Prompt window you can use the cd, md, and dir commands. Here is a brief description of each of these commands along with some examples. For more complete information on each of these commands you can issue the command help followed by the command name.

The cd command The cd command is used to change or display the current directory.
cd C:\TEMP changes the current directory to C:\TEMP
cd .. changes the current directory to the parent directory
cd displays the current directory
md command The md command is used to make a directory or sub-directory
md C:\progfun makes a directory named progfun on the C drive
md progfun makes a subdirectory named progfun in the current directory
The dir command The dir command is used to display the contents of a directory.
dir displays the contents of the current directory
dir C:\progfun displays the contents of the directory named C:\progfun
dir progfun displays the contents of the subdirectory named progfun

You might consider printing this Sidebar as it may come in handy as you work on the exercises in this module.
Using Command Prompt window (Unix)
In the next lesson you will install the Java 2 Software Development Kit.

Create Windows Directory - Exercises

Click the Exercise link below to create a directory for your programs (Windows).
Create Windows Directory - Exercises

Create Unix Directory - Exercise

Click the Exercise link below to create a directory for your programs (Unix).
Create Unix Directory - Exercise