Programmer's Survival Guide for Windows

CMD Shell, File System & Source-code Editors

Command-Line "CMD"

Programmers use a command-line interface (CLI) to issue text-commands to the Operating System, instead of clicking or double-clicking on a Graphical User Interface (GUI). This is because command-line is much more powerful than the graphical interface.

The CMD (Command Interpreter or Command Prompt) is a command-line Interface. It supports a set of commands and utilities; and has its own programming language for writing batch files (or shell scripts).

You can launch a CMD via:

  1. "Start" button ⇒ "Run..." ⇒ Enter "cmd", or
  2. "Start" button ⇒ All Programs ⇒ Accessories ⇒ Command Prompt.

The CMD displays a prompt which ends with a ">", in the form of "drive:\current-directory>". You can enter your command after the prompt.

File System and Commands


In Windows, files are organized in directories (aka folders). The directories are organized in a hierarchical tree structure, starting from the so-called root directory for each of the hard drive (as illustrated). A directory may contain sub-directories and files. A sub-directory may contain sub-sub-directories and files, and so on.

Windows' file system is further organized in drives, identified by a drive letter followed by a colon, e.g., C:, D: and E:. Each drive has its own root directory, such as C:\, D:\ and E:\, where the "\" (back-slash) denote the root directory of each drive.

Windows' file system is NOT case-sensitive, a rose is a Rose, and is a ROSE.

Filename and File Type

A Windows' filename consists of two parts: filename and file type (or file extension) separated by a dot, e.g.,, Hello.class, Test.txt, etc. Windows can associate a program to each file type. For example, double-clicking a .txt invokes NotePad; double-clicking .jpg invokes Photo or Paint.

For programmers, it is important to SEE the file type inside the File Explorer, which is hidden by default. For example, "" is displayed as "Hello" with the "type" of "JAVA file".

To view the file type, launch "File Explorer" ⇒ View ⇒ Option ⇒ "View" Tab ⇒ Uncheck "Hide extensions for known file types" (or Control Panel ⇒ File Explorer Options or File Options or View Options ⇒ "View" Tab ⇒ Uncheck "Hide extensions for known file types").

Drive-Letter, Pathname and Filename

To reference a file in Windows' file system, you need to provide the drive letter, the directory name (aka pathname) and the filename. For example, in "C:\Program Files\java\jdk1.7.0_07\bin\javac.exe", the drive is C:, the pathname is "\Program Files\java\jdk1.7.0_07\bin\" and the filename is "javac.exe". The leading "\" (back-slash) denotes the root directory for that drive. The sub-directories are separated by "\" (back-slash).

The pathname can be specified in two ways:

  1. Absolute Pathname: An absolute pathname begins from the root directory of a drive. It starts with X:\ (where X denotes the drive letter and the leading "\" denotes the root), and contains all the sub-directories leading to the file (separated by "\"). For example, "C:\Program Files\java\jdk1.7.0_07\bin\".
  2. Relative Pathname: A relative pathname is relative to the so-called current drive and current working directory. For example, if the current drive and working directory is "C:\Program Files\java\", then the relative path "jdk1.7.0_07\bin\" resolves to "C:\Program Files\java\jdk1.7.0_07\bin\". A relative pathname does NOT begin with a leading "\" (back-slash).

Current Drive and Current Working Directory

Each CMD session maintains a so-called current drive and current working directory, which is shown in the prompt in the form of "drive:\current-directory>". All relative pathnames/filenames are relative to this current drive and working directory.

Set Current Drive (x:) Command

To set or change the current drive, enter the drive letter followed by a colon (:), e.g.,

Prompt> d:    // Change the current drive to D. The prompt changes to D:\...
D:\...> c:    // Change the current drive to C. The prompt changes to C:\...

Change Directory (cd) Command

To change current working directory, under the current drive, use command "cd new-path" (change directory).

It is important to take note that you need to set the current drive first (via "x:" command) before setting the current directory under the current drive.

You can specify new-path in two ways: absolute or relative. An absolute path begins with a "\" or root directory. A relative path is relative to the current working directory and does NOT begin with a leading "\". For example,

Prompt> c:
   // Set current drive to C. The prompt changes to C:\...
C:\....> cd \           
   // Set current directory to the root directory of the current drive
C:\> cd Windows
   // Set current directory to "Windows" relative to current directory of the current drive
C:\Windows> cd system
   // Set current directory to "system" relative to current directory of the current drive
C:\Windows\system> cd \myproject\java
   // Set current directory absolutely to "\myproject\java" of the current drive
C:\myproject\java> cd "\Program Files\java\jdk1.7.0_07\bin"
   // Set current directory absolutely. Enclosed with double quotes if pathname contains blank.
C:\Program Files\java\jdk1.7.0_07\bin> d:
   // Set the current drive to D drive
D:\....> cd \
   // Change directory to the root of the current drive
D:\> cd Java
   // Change directory to the "Java" sub-directory of the current directory

Take note that:

  1. You need to set the current drive and current directory in two commands: X: and cd.
  2. The current drive and current working directory is displayed in the command prompt before the ">".

You can cd in multiple stages (e.g., one cd for each sub-directory - recommended), or cd in one single stage with the full pathname.

Prompt> c:                                  // C:\...
C:\....> cd \                               // C:\
C:\> cd Program Files                       // C:\Program Files
C:\Program Files> cd java                   // C:\Program Files\java
C:\Program Files\java> cd jdk1.7.0_07       // C:\Program Files\java\jdk1.7.0_07
C:\Program Files\java\jdk1.7.0_07> cd bin   // C:\Program Files\java\jdk1.7.0_07\bin
C:\Program Files\java\jdk1.7.0_07\bin>
// Same As
Prompt> c:
C:\....> cd \Program Files\java\jdk1.7.0_07\bin
C:\Program Files\java\jdk1.7.0_07\bin>

You can use ".." (double-dot) to refer to the parent directory and "." (single-dot) to refer to current directory. For example,

C:\Program Files\java\jdk1.7.0_07\bin> cd ..   // Parent directory
C:\Program Files\java\jdk1.7.0_07> cd ..
C:\Program Files\java> cd ..
C:\Program Files>

Setting proper working directory is important. For example, to compile a Java program called "" stored in "D:\myproject\java\":

  1. Set the working directory to "D:\myproject\java\", and reference the file relatively with filename only (without the path):
    Prompt> d:
    D:\...> cd \myproject\java
    D:\myproject\java> javac   // Filename only, in current directory
  2. You can also refer to a file with its full path in any working directory:
    // Any working directory
    Prompt> javac d:\myproject\java\

Directory (dir) Command

You can list the contents of the current directory via the dir command, for example,

Prompt> dir              // List of contents of the current directory
Prompt> dir   // Show the file "" only
Wildcards * and ?

You can use wildcards for pattern matching. The wildcard * matches zero or more (any) characters; ? matches one (any) character.

Prompt> dir *.java  // List files ending with ".java"
Prompt> dir test*   // List files starting with "test"

(Windows) Graphical Interface - File Explorer

You could, of course, view the contents of a directory (folder) using the Windows' "File Explorer" more conveniently. But,

  • Windows' File Explorer, by default, will not show the file extension. For example, "Hello.txt" will be listed as "Hello" with Type of "TXT File". To display the file extension, choose "View" menu ⇒ Check "File name extensions". (In older version of Windows, goto "Control Panel" ⇒ File Explorer Option (or View Option) ⇒ View ⇒ Uncheck "Hide extensions for known file types".)
  • Windows' File Explorer, by default, will not display hidden files and directories (e.g., "C:\ProgramData"). To display the hidden items, choose "View" menu, check "Hidden Items".
Tips and Tricks
  • You can click on the "folder name" to get the full pathname of the current folder.

Shortcut Keys in CMD Shell - IMPORTANT

Previous Commands in Command History: You can use the up/down arrow keys to scroll through the previous/next command in the command history.

Auto-Complete with TAB: Type the first few characters of a filen/directory name, and press TAB key to auto-complete the file/directory name. Press TAB key repeatably to cycle through all the matches.

Copy/Paste: In the latest CMD, you can use Ctrl-c/Ctrl-v for Copy/Paste, by enabling "Enable Ctrl Key Shortcuts" (via click on the CMD icon (top-left corner) ⇒ Properties ⇒ Options ⇒ Edit Options ⇒ Check "Enable Ctrl Key Shortcuts").

(In the earlier version of CMD, you need to enable Copy/Paste by clicking on the CMD icon (top-left corner) ⇒ Properties ⇒ Options ⇒ Edit Options ⇒ Check "QuickEdit Mode". Once enabled, you can right-click to copy the highlighted text, and another right-click to paste on the command-line.)

Moving the Command-Line Cursor: In CMD, you CANNOT use mouse pointer to move the command-line cursor. Instead, you need to use Left/Right-Arrow, Backspace or Delete keys to move the command-line cursor.

These are the various ways of moving the command-line cursor:

  • Left/Right Arrow Key: Move the cursor one character to the left/right.
  • Backspace/Delete Key: delete the previous/current character unde the cursor.
  • ESC Key: Clear command-line.
  • Home/End Keys: Move the the begin/end of command line.
  • Ctrl + Left/Right-Arrow Key: Move one "word" to the left/right.
Tips and Tweaks for CMD
  1. CMD is NOT case-sensitive.
  2. The screen buffer size (controlling the amount of messages retained in the screen) can be configured under "CMD icon" ⇒ "Properties" ⇒ "Layout". You should set to a bigger number (500-2000), so that you can view more old messages.
  3. You can also change the colors and font via "CMD icon" ⇒ "Properties" ⇒ "Colors" and "Properties" ⇒ "Font".

Keyboard Shortcuts (for Windows)

Good programmers uses keyboard shortcuts instead of mouse to perform most of the editing tasks, such as positioning the cursor, selecting texts, copy and paste. Below are the frequently-used keyboard shortcuts for the programmers.

Keyboard Shortcut Function
Ctrl+c, Ctrl+v, Ctrl+x Copy, Paste, Cut
Ctrl+s Save
Ctrl+f Find
Ctrl+z, Ctrl+y Undo, Redo
Ctrl+RightArrow, Ctrl+LeftArrow Goto next/previous word
Home, End Goto begin/end of the current line
Ctrl+Home, Ctrl+End Goto top/end of document
Ctrl+a Select all
Ctrl+Shift+RightArrow, Ctrl+Shift+LeftArrow Select words
Shift+DownArrow, Shift+UpArrow Select lines
Shift+RightArrow, Shift+LeftArrow Select characters
Shift+End, Shift+Home Select till end/begin of current line
Alt+Tab Switch between open applications
Alt+F4 Close the current application
Mouse Clicks
  1. Single-click to position the mouse pointer.
  2. Double-click to select a word.
  3. Triple-click to select a paragraph.

Source-Code Editors (for Windows)

A program editor (or source code editor) is programming language sensitive and context-aware. It highlights the syntax elements of your programs; and provides many features that aid in your program development (such as auto-complete, compile/build/run, help menu, etc.). On the other hand, a plain text editor, such as "NotePad", is not language-sensitive and, therefore, is NOT suitable for writing programs. For full-scale software development, you should use an appropriate IDE (Integrated Development Environment).

It is important to use a mono-space font (such as "Courier New", "Consola") for programming, so that the columns are properly aligned.

There are tons of "free" program editors available. Google "best source code editor" to find out the latest. Here are some program editors that I am currently using. Unfortunately, there isn't one magic wane (or silver bullet) that suits all my programming needs.


TextPad is an excellent source-code editor, especially for writing toy Java programs. It is simple to use, fast to launch, and it can be configured to run JDK commands directly. TextPad is a shareware (not a freeware). The full-function version can be downloaded from It has no time limit but a message will keep reminding you to purchase the shareware.

To install, simply run the downloaded installer.

Using TextPad for Writing Toy Java Programs

TextPad is great in writing toy Java programs, as it can be configured to run JDK command directly, bypassing the command shell. From the TextPad editor, you can invoke the JDK compiler and runtime directly via "Tools" ⇒ (Version 5 only) "External Tools" ⇒ "Compile Java" or "Run Java Application". Take note of the keyboard shortcuts.


If you cannot find these commands in the "Tools" menu, goto "Configure" ⇒ Preferences... ⇒ Tools ⇒ Add ⇒ JDK Commands. You can also configure the attributes of "compile" and "run" there, such as prompting for command-line arguments.

Tips for Using TextPad
  1. Error Message Hyperlink: Double-click on the first-line of an error message will hyperlink to the corresponding source statement.
  2. Find & Replace: Most important commands for programmers (after the copy/paste), available under the "Search" menu.
  3. Block Select Mode: The Block Select mode allows you to operate on a block of texts, such as deleting a few columns and filling in blank columns. To enable/disable Block Select mode, select "Configure" menu ⇒ check/uncheck "Block Select Mode".
  4. Line Numbers: To display the line numbers, choose "View" menu ⇒ check the "Line Number" option.
  5. Command-Line Arguments: To provide command-line arguments to your Java program in TextPad, choose "Configure" menu ⇒ "Tools" ⇒ "Run Java Application" ⇒ check "Prompt for parameters" box. When running your program, place your command-line arguments after $BaseName (which denotes the Java program name).
Configuring TextPad

TextPad is highly configurable to suit your personal programming style (such as your preferred font, color, layout, tab spaces, etc). Select "Configure" menu ⇒ Preferences.

  1. Font: "Configure" ⇒ "Preferences" ⇒ Expand "Document classes" node ⇒ Select your desired class, e.g., "Java", and expand the node ⇒ "Font" ⇒ Select monospace font for programming, e.g., Courier New, Courier, Consola, Lucida Console.
  2. Add File Association (e.g., *.xml to use HTML Syntax Highlighting): "Configure" ⇒ "Preferences" ⇒ Expand "Document classes" node ⇒ Click on your desired class, e.g., "HTML" ⇒ In "Files in class xxx", add your file extension, e.g., *.xml, *.jsp.
TextPad Common Errors
ERROR MESSAGE: error: illegal character: \29
  You has non-printable character "\29" (Ctrl-]) in your source code. (You probably meant to use Shift-] for '}'.)
  Remove this character if you can figure out its location. Otherwise, remove the whole line and re-enter the line.


NotePad++ is an open-source and free program editor that supports syntax highlighting for many languages. It is meant as a "Notepad replacement". You can download NotePad++ from


Notepad++ is highly expandable via third-party plug-ins. Google "notepad++ plug-in" to search for plug-in. To install a plug-in, download, unzip, and move the "dll" file into notepad++'s "plugins" directory.

These are the useful plug-ins:

  1. Hex Editor Plug-in: The hex editor plug-in allows you to view/edit binary files in hex codes. Google "notepad++ plugin hex editor", or from ⇒ from the file list, select "Hex Editor" ⇒ download ⇒ unzip ⇒ move the dll file into notepad++'s "plugins" directory. The Hex Editor will be available from the "Plugins" menu ⇒ "Hex Editor", or the "H" icon on the menu bar.
Tips on Using NotePad++
  1. Reformatting Source Code: TextFX ⇒ TextFXEdit ⇒ Re-indent C++ Code (which also work for java codes).
  2. Block Select: You can select columns of text by holding down the Alt key while selecting (similar to WinWord).
  3. Converting Source Code to HTML: TextFX ⇒ TextFXConvert ⇒ Encode HTML (&<>").
  4. Converting End-of-line (EOL) between Windows, Mac and Unix: Edit ⇒ EOL Conversion ⇒ Choose Windows, Unix or Mac format.
  5. Tile 2 Windows: Right-click on a window ⇒ Move to other view.
NotePad++ for Java Programming

To compile and run Java programs with a single hot-key (just like TextPad), I wrote two batch files called "NppJavaCompile.bat" and "NppJavaRun.bat" and save them in the NotePad++ installed directory (or a directory in the PATH).

@REM To run with: NppJavaCompile $(CURRENT_DIRECTORY) $(FILE_NAME)
@cd /d %1
@echo Check if you have save your source file?
javac %2
@REM To run with: NppJavaRun $(CURRENT_DIRECTORY) $(NAME_PART)
@cd /d %1
java %2

To install the batch files, select the "Run" menu ⇒ "Run...", enter "NppJavaCompile $(CURRENT_DIRECTORY) $(FILE_NAME)" ⇒ Choose "Ctrl-1" as the hot-key for compiling Java program. Similarly, select the "Run" menu ⇒ "Run...", enter "NppJavaRun $(CURRENT_DIRECTORY) $(NAME_PART)" ⇒ Choose "Ctrl-2" as the hot-key for running Java program. (To use Ctrl-1, Ctrl-2, you need to re-configure and remove the existing mappings for these keys via "Settings" ⇒ "Shortcut Mapper...".)

These are the notepad++ internal variables:

  • $(FULL_CURRENT_PATH): the fully qualified path and name to the current document.
  • $(CURRENT_DIRECTORY): The directory the current document resides in.
  • $(FILE_NAME): The filename of the document, without the directory.
  • $(NAME_PART): The filename without the extension.
  • $(EXT_PART): The extension of the current document.

To modify the commands, you need to edit "shortcuts.xml" (search under your user's AppDate directory).

Using NppExec Plugin

The above Compile-Java batch file, unfortunately, does not automatically save the current file before running the compilation. To automatically save the file, I have to use the "NppExec" Plugin, as follows:

  1. Goto "Plugins" menu ⇒ Select "NppExec". (If you cannot find "NppExec" under plugins, you need to first install the "NppExec" plugin.)
  2. Choose "Execute..." and enter the following commands:
    javac $(FILE_NAME)
    Save it as script name "JavaCompile".
  3. Press "OK" to run the script. You shall see the output on the NppExec's console.
  4. To install a hot-key for this NppExec script:
    1. From "Plugins" menu ⇒ Select "NppExec" ⇒ "Advanced Options...".
    2. In "Menu Item" ⇒ "Associated script" ⇒ Select the script "JavaCompile" ⇒ "Add/Modify". You shall see the item appears in the "Menu Items". If you open the NppExec menu, you will see "Java-Compile" as a menu item.
    3. To install a hot-key (such as Ctrl-1 - make sure it is not used) ⇒ Goto "Settings" ⇒ "Shortcut Mapper" ⇒ "Plugin Commands" ⇒ Select "JavaCompile" ⇒ Modify ⇒ Assign your chosen hot-key.

The above "NppJavaRun" batch file is fine, as there is no need to save the current file.

NotePad++ for C++ Programming

Similarly, these scripts are used for compiling toy C++ programs using g++.

@REM Need to save the source file before running this script?!!
cd /D %1

g++ -Wall -g %2.cpp -o %2
ECHO g++ -Wall -g %2.cpp -o %2

gcc -Wall -g %2.c -o %2
ECHO gcc -Wall -g %2.c -o %2

@cd %1

Sublime Text 3

"A sophisticated text editor for code, markup and prose" @

Tips & Tricks
  1. Ctrl++ and Ctrl+- to zoom in or out (increase/decrease font size) (Similar to web browser, but Ctrl-0 doesn't work).
Compile and Run Java Program (For Windows)
  1. Edit "%APPDATA%\Sublime Text 3\Packages\Java\JavaC.sublime-build", or create a new file if it does not exist. Issue "echo %APPDATA%" to find its directory.
  2. Copy or replace with the following code:
      "shell_cmd": "start cmd /k \"javac $file_name && java $file_base_name\"",
      "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
      "selector": "",
      "shell": true
    The above build file issue a "start cmd /k" to start a new cmd shell (so that the program can accept user input from keyboard) and run Java compile command "javac $file_name" followed by Java run command "java $file_base_name".
  3. Goto "Tools" ⇒ "Build System" ⇒ choose "JavaC" to select the above build file (only need to do once).
  4. Now you can use Ctrl+B (or "Tools" ⇒ "Build") to compile and run the Java program, in a new cmd window.

[TODO] Need to figure out the build-file path for Unix/Mac OS, and also the command to start a new bash shell.


"A hackable text editor for the 21st Century" @


Other Program Editors


PSPad is an excellent program editor, especially for web programming such as writing JavaScript. It is a freeware and can be download from To install, simply run the downloaded installer. The "Help" menu provides many good links to various online programming guides and references.



Light Table


Hex Editors

At times, you may need to display the hex values of a file. A Hex Editor is a handy tool that a good programmer should have in his/her toolbox. There are many freeware/shareware Hex Editor available. Try google "Hex Editor".

I recommend "Notepad++ with the Hex Editor plugin". Read "NotePad++".



  1. Microsoft MS-DOS User's Guide and Reference.
  2. "Microsoft XP Professional Product Documentation - Command-line reference", [online].
  3. "Microsoft XP Professional Product Documentation - Using batch file", [online].
  4. "Command-line Reference for IT Pros - Technical Reference", available under Windows "Help".