Basic MS-DOS Commands for CSCI Students


Last modified: 14 August 2009, 4:30 pm

Essential Commands File Management Java compiler, JVM Java documentation Java archives (JAR) Environment Variables

Essential Commands

dir Lists names of files in current directory (folder)
dir Hello.* Lists all files whose names start with Hello.
cd C:\files Changes directory to C:\files ("absolute" pathname)
cd myfiles Changes directory to myfiles subdirectory of current directory ("relative" pathname)
cd .. Changes directory to "parent" of current directory
notepad Hello.java MS-DOS text editor, used to create and edit ASCII textfiles
type Hello.java Displays contents of ASCII textfile on screen
exit Ends command interpreter, makes console window go away...

Useful File Management Commands

copy Test1.java Test2.java Copies contents of Test1.java to new file Test2.java
ren Test1.java Test2.java Renames Test1.java to Test2.java
del Test1.java Deletes Test1.java (Be careful with this command...)
del Test1.* Deletes all files with Test1 prefix (Be even more careful with this command...)
mkdir playpen Creates new directory playpen as subdirectory of current directory
rmdir playpen Removes directory playpen (must be empty)

Commands for Compiling and Running Java Applications

Note: if the commands in this table are not recognized by the MS-DOS command interpreter on your system, try using the path commands listed below...

javac Hello.java Compiles Java source file Hello.java (ASCII textfile),
produces bytecode file Hello.class (binary file)
java Hello "Runs" Java application: starts Java Virtual Machine (interpreter),
which executes Java bytecode instructions in file Hello.class

Using javadoc to Document Java Classes

Note: if the commands in this table are not recognized by the MS-DOS command interpreter on your system, try using the path commands listed below...

javadoc Cat Generates Web document Cat.html, containing description of Cat class. Complete documentation requires inclusion of javadoc comments (/** .. */) in source code.

Jar (Java Archive) Commands

Note: if the commands in this table are not recognized by the MS-DOS command interpreter on your system, try using the path commands listed below...

jar cf Pets.jar Pets Creates Pets.jar, containing compressed version of Pets folder and all its contents
jar tf Pets.jar Displays list of zipped files in Pets.jar
jar xf Pets.jar Extracts (unzips) entire contents of Pets.jar, preserving any directory structures

Commands for Manipulating Environment Variables

path Displays current value of PATH environment variable (list of directories containing DOS command programs)
set path=C:\Program Files\Java\jdk1.6.0_15\bin;%PATH% Adds named directory (a JDK system directory in this example) to current PATH environment variable (applies only to current session).