DOS Commands

Objectives

  • Use some basic DOS (command prompt/console) commands
  • Discuss some naming conventions
  • Describe some Java naming rules

List of commonly used commands

Note: Windows and the command prompt are NOT case sensitive, but Java is. You can type a command like "dir" in upper or lower case. You can even type the name of Java commands in upper or lower case. Just make sure that any arguments that you send to the Java commands are in the correct case.

CommandWhat it does
dirlists contents of current working directory
clsclears the screen
h:changes current working directory to drive H
cd dir1changes the current working directory to a child directory named "dir1" - if it exists
cd ..changes the current working directory to the parent of the current working directory
cd \changes the current working directory to the root directory of the current working drive
mkdir dir1create a child directory named "dir1" in the current working directory
rmdir dir1deletes a child directory named "dir1" - if it exists
erase file1erases a file named "file1" in the current working directory - if it exists
rename file1 file2renames "file1" to "file2" - if file1 exists and file2 does not exist
copy file1 file2makes a copy of "file1" and names it "file2" - if file1 exists and file2 does not exist
helpdisplays a list of all the DOS/command prompt commands that are available
help commanddisplays detailed usage information on the specified command
javac MyProgram.javacompiles MyProgram.java into MyProgram.class - this is part of Java, not DOS
java MyProgramruns MyProgram.class using the JVM - this is part of Java, not DOS

Notes

  • Avoid using spaces and other unusual characters in file and directory names.
  • Names are best when starting with a letter and consisting of only letters, digits, and the underscore character.
  • One exception to the naming rule is the period used before the filename extension.
  • All Java program source files must have the .java extension.
  • A Java source file must have the same name as the top-level public class in the source file (if there is one).
  • Camel-case is a naming convention where the first letter of each word is uppercase, but all other letters are lowercase.
  • Example of a camel-casing: hourlyRate, BenefitCalculator
  • In Java, class names start with an uppercase letter and are camel-cased.
  • In Java, method and variable names start with a lowercase letter and are camel-cased.
  • In Java, names (identifiers) contain only letters, digits, the dollar sign, and the underscore character.
  • In Java, names (identifiers) may not start with a digit.
  • In Java, names (identifiers) are case-sensitive.