Survival DOS Copyright Charles W. Neville, 1998. 1. Directories: In common with most other operating systems, DOS has a hierarchical directory structure. This means that a DOS disk can be subdivided into DIRECTORIES (also called FOLDERS) so that related files can be grouped together. People often make the analogy that a DOS disk is like a file cabinet, and a DOS directory is like a file folder in a file drawer. In this analogy, DOS files are like the individual documents in the file folders. Just as a sensible person groups related documents together in a file folder, so too would such a person group related DOS files together in a DOS directory. Directory Commands: dir -- see the names of files in the current directory. md -- make (create) a DOS directory. Example: md javademos creates a directory which (presumably) you would use to hold your java demo programs. cd -- change the current directory. Example: cd javademos puts you in the javademos directory, so you can work on files there. The cd command is analogous to opening a file folder in a file drawer so you can work with the documents in the file folder. .. -- the parent directory of the current directory. Example: If you are in the javademos directory, cd .. gets you out of the javademos directory and back to the parent directory of javademos. \ -- the root directory on the current disk. Example: cd \ gets you back to the main directory of the current disk drive. Path Syntax: Examples: A:\cs151\javademos refers to the javademos subdirectory of the cs151 directory of the A: drive. (A: is the floppy disk drive.) C:\Programs\VisualCafePDE\Java\Bin\javac.exe refers to the javac.exe file (the Java compiler) in the Bin subdirectory of the Java subdirectory of the VisualCafe subdirectory of the Programs directory of the C: drive. (C: is the hard disk drive located inside the cabinet of the computer you are sitting at.) An Example Directory Structure (for an imaginary example machine): C:\ (root directory on C: drive) | ---------------------------------------------------------- | | | Programs (directory) autoexec.bat (file) Accessories (directory) | | ---------------------------- ----------------------------------- | | various files including Notepad.exe VisualCafePDE (directory) WorkviewOffice (directory) | | --------------------- -------------------------------- | | Various files and subdirectories Java (directory) Demos (directory) | | ----------- ------------------------ | | | Bin (directory) AmazingTour.java (file) AmazingTour.class (file) | --------------------------------------------- | | | appletviewer.exe (file) java.exe (file) javac.exe (file) Problem: Find the complete path to AmazingTour.java Solution: C:\Programs\VisualCafePDE\Demos\AmazingTour.java Problem: You are in C:\Programs\VisualCafePDE\Java\Bin. You want to get quickly to C:\Accessories. What do you type? Solution: cd C:\Accessories Problem: You are in C:\Programs\VisualCafePDE\Demos. You want to get quickly to C:\Programs\VisualCafePDE. What do you type? Solution: Where you want to go is the parent directory of where you are, so you simply type cd .. File Commands: copy -- copy a file Example: copy myFile.java yourFile.java creates a copy of myFile.java named yourFile.java. myFile.java must already exist. (Perhaps you created it in Notepad.) rename -- rename a file Example: rename yourFile.java herFile.java changes the name of yourFile.java to herFile.java Example: rename myProgram.java.txt myProgram.java changes the name of myProgram.java.txt to myProgram.java. Unfortunately, you may have to use this particular rename command alot, because Notepad tends to stick a gratuitous .txt onto the end of the name of any file it creates. del -- delete a file Example: del herFile.java deletes herFile.java. This means herFile.java no longer exists. NOTE: Be careful with the del command. If you delete a file and don't have a copy of it lying around anywhere, then all of the information in the file is GONE FOREVER to the GREAT BIG BIT BUCKET UP IN THE SKY. Problem: You are in the root directory of the A: drive. You want to copy AmazingTour.java to your floppy disk. (Refer to the "Example Directory Structure" diagram located above to see where AmazingTour.java lives.) What do you type? Solution: copy C:\Programs\VisualCafePDE\Demos\AmazingTour.java A: The PATH Command: This is probably the hardest thing we have covered so far. Certainly, it is the most arcane. PATH is an environment variable that tells DOS where to look for files. Usually, PATH will be set correctly (that is have the correct value) so you can just type javac to invoke the Java compiler. But sometimes a machine will, for whatever reason, NOT have its PATH variable set correctly. In this case, when you type javac, DOS will respond with an error message because it can't find the program javac.exe. For example, if the value of PATH were set to C:\;C:\Winnt.0\System32 then when you type javac DOS will look for the javac.exe program in the root directory of the C: drive (C:\) and the System32 subdirectory of the Winnt.0 directory of the C: drive (C:\Winnt.0\System32) and the current directory (probably A:\). We know javac.exe is not located in any of these places. (Look at the "Example Directory Structure" diagram to see where it is on our fictitious example machine.) What do you do? One solution is to type the FULL PATH to javac.exe, that is to type C:\Programs\VisualCafePDE\Java\Bin\javac.exe everytime you want to invoke the Java compiler. This works, but it certainly is clumsy. A better solution is to reset the PATH variable so it is correct. To do this, just type the string PATH C:\Programs\VisualCafePDE\Java\Bin;%PATH% This is complicated, but it has the great advantage that you only have to do it once. Afterwards, everytime you type javac DOS will be able to find the javac.exe program and your file will compile.