Create Software Components 

Using Java Level 2



Course Info




Java Demos




  Lecture 1

A Little Bit Of DOS

The Java 2 SDK tools such as javac, appletviewer, java, etc. that you use to compile and run your Java programs, must be run from a command prompt window.  Using the command prompt window efficiently requires some rudimentary knowledge of DOS.  Read on to learn some DOS basics.

What is DOS?

The DOS View of Files & Folders

The useful DOSKEY

Table of DOS Commands

What is DOS?

MS-DOS is an operating system with a command-line interface rather than a graphical user interface.  

In Windows you can open a  command prompt window which lets you type in MS-DOS commands. Just click the Start button, point to All Programs, point to Accessories, and then click Command Prompt.

To end your MS-DOS session, type exit in the command prompt window at the blinking cursor or just close the command prompt window by clicking the button.

The picture below shows a typical command prompt window.



DOS is an entirely text based system. The first thing to note about the command prompt window is the C:\> prompt and the blinking cursor next to it.  This is where you type in commands.

You should note that DOS is entirely case insensitive: so for example, typing in either "help:" or "HeLp" would bring up a list of commands you can use.  However, don't forget that Java is not case insensitive

The DOS View of Files and Folders

What is this C:\> prompt?  

The C represents your root folder on your hard drive.  Every disk drive has a root folder, which can have subfolders.  The hard disk root folder is usually called the C:\> while the floppy disk root folder is usually called the A:\

Root folders can have subfolders which can also have subfolders and so on. 

As an example, here is a Windows Explorer view of some of the folders on my floppy.


Now lets see the DOS view of my floppy.


We can see that my A:\ has a folder in it called myStuff and there are two subfolders in that folder called docs and pics.  The docs folder also has a subfolder in it called code.  

Now, to see what's in the code folder I can type:-

dir A:\myStuff\docs\code

The dir command tells DOS to list all items such as files and subfolders in a folder. The rest of the command A:\myStuff\docs\code is an example of a PATH and tells DOS that I want the list to be of the items in the  code folder.  Lets see what I get...

The third line show I have a file in the code folder called

    Understanding Filenames  

The standard DOS filename is comprised of a file name 1 to 8 letters long, then a period, then a 3-letter extension e.g.  


The extension to a file's name is indicates what type of file it is.  I.e. all word processor files might have the extension .doc, while all picture files might have the extension .bmp.  

While the user can specify these extensions, many programs use them to differentiate between formats, and so they have gradually become standardized. For example, you would expect a .txt file to be a file containing unformatted text, or a .bmp file to be in a bit mapped graphics file format. 

    Understanding Paths      

To completely specify a file on your computer you must specify its drive, it's folder path and its filename. E.g.


A path includes the disk drive and all subfolders needed to specify where the folder is on a disk.  E.g.


A colon follows the drive letter and the folder path names are separated by backward slashes (\), (not forward slashes like internet addresses).

However a file does not always have to be specified in this complete form:  if it is in the current folder, then you can just enter its filename. 

    Current Folder           

A useful DOS command is cd

This tells DOS to change the current folder.  Just like in Windows where you go into different folders using My Computer, you can change the folder you are in with DOS too. Here is an example.

cd A:\myStuff\docs\code

Lets see what happens...

I have now changed my current folder from A:\ to  A:\myStuff\docs\code

I can tell this is the case because the prompt has changed from A:\> to  A:\myStuff\docs\code>

Now I can list the items in the code folder in two ways...

dir A:\myStuff\docs\code

or just


This brings up the same list as before.  So, if you don't specify a path then DOS assumes that you are referring to your current folder.

The Useful DOSKEY

If there is a command you execute very often, you might want to use a small utility called DOSKEY, which comes free with DOS. The program loads up and stays in the memory. It then 'remembers' the last few commands that are issued at the prompt. To reuse a command, you can make use of the arrow keys and function keys.

The UP and DOWN arrow keys display the previous command or, if in the middle of the list, the next command. This trick saves some typing.  You can use various function keys as follows:-

[F7] key:  This will display all the commands that are currently stored in memory.  The list displays the commands with a number, that could also be used to call a command quickly. 

[F9] key:  If you know the commands number then press [F9] and then the command's number and the command will be displayed on the prompt line. 

Rather than remembering silly numbers, that will change when more commands get added to the list and others drop off, you could key in the first few characters and then press [F8] to recall the command.

[ESC] clears the commands history.

How do you know if you have DOSKEY running?   Type in 

doskey /? 

at the command prompt and you will get a list of parameters.

Note: --  In Windows XP and 2000, DOSKEY should be automatically running.  

In Windows 98 you may have to run DOSKEY manually each time you open a command prompt window by typing doskey at the prompt..  

To get it to run automatically every time you open a command prompt  window, access the properties sheet for the command prompt window and add the command C:\WINDOWS\COMMAND\DOSKEY.COM as the startup batch file.  Now, close the command prompt window. The next time you open an command prompt window, DOSKEY will load automatically.



A Table of DOS Commands

Here are some useful DOS commands

A: - Change current folder path to the floppy disk drive

C: - Change current folder path to the hard disk drive

DIR - Display current folder contents (show all files and sub- folder). e.g.


list all the items in the code folder

CD - Change the current folder, e.g.

A:\myStuff\docs\code>cd C:\docs

changes the current folder to a folder called docs on the C drive

CD \ - Change the current folder to the root folder.  e.g.

A:\myStuff\docs\code>cd \

changes the current folder to the root folder.  In this case the A: drive is the root.

CD.. - Change the current folder to the parent folder of the folder you are in.  e.g.


changes the current folder to


MD - Make a new folder. e.g.:

A:\myStuff\docs>md foo

this makes a new subfolder called foo in the current folder

RD - deletes a folder, provided it is empty. e.g.

A:\myStuff\docs>rd foo

this deletes a subfolder of docs called foo

DEL - deletes a file. e.g.

A:\myStuff\docs>del afile.txt

would delete a file called afile.txt from the docs folder

Move - Move file(s) from one place to another. 

e.g. type the following, all on one line...

move A:\myStuff\docs\code\*.* C:\docs

this moves all the files in the code folder on the floppy to a folder called docs in the C drive. The  *.* means all files. 

COPY - Copy file(s) from one place to another. 

e.g. type the following, all on one line...

copy A:\myStuff\docs\code\*.* C:\docs

this copies all the files in the code folder on the floppy to a folder called docs in the C drive. The  *.* means all files.



That is folks!!

Now try the DOS exercise



  Site Home 

Java Home   


Course Info





Scheme of Work





Learning Center

Web Materials


Java Demos



Lecture Materials

Tutorials & Notes





Site Home


Unit Home

ADR 2002