Contributed by 
Mark Armbrust
25 June 2014
Extract this archive into your nand2tetris/tools directory.
  NewBatShFiles.zip
It replaces the *.bat and *.zip files that run the Nand2Tetris tools.
Add your nand2tetris/tools directory to your PATH variable.
Then you can use the tools directly from the command line.  For example:
    JackCompiler              Compiles all .jack files in the current
                              working directory.
    JackCompiler DIRECTORY    Compiles all .jack files in DIRECTORY.
    JackCompiler FILE.jack    Compiles FILE.jack to FILE.vm.
These have been tested on Windows XP and 7, and on Linux (Ubuntu) and Mac OS X.
NewBatShFiles.html from the zip file:
This archive contains updated batch files and scripts for the Nand2Tetris 
tools.  These batch files and scripts can be used from any working directory 
without requiring full paths for their arguments.
The batch files have been tested on Windows XP and Windows 7 32- and 64-bit.  
The scripts have been tested on Ubuntu Linux and Mac OS X.
For these batch files or scripts from the command line, you must add the 
nand2tetris/tools directory to your PATH variable.  The batch files 
and scripts do handle spaces in directory and file names so they will 
work if Nand2Tetris is installed under "My Documents".
On Windows, the batch files will run by just typing their name (without 
the .bat).  On Linux and Mac OS X you must change the scripts' attributes to
include "executable".  It's also handy to make symbolic links [1] in your 
~/bin 
directory so that you don't need to type the .sh:
ln -s ~/nand2tetris/tools/Assembler.sh Assembler
chmod +x Assembler
Note that on Windows 7 64-bit you need to install the 64-bit version of 
Java so that 64-bit cmd.exe can run java commands in batch files.  If the 
batch files say " 'java' is not recognized..." you likely only have the 32-bit 
Java installed.
On Windows, you can create desktop icons for the interactive tools – 
HardwareSimulator, Assembler, CPUEmulator and VMEmulator – 
by finding them in Explorer and right-clicking on them and pick 
"Send to > Desktop."  Edit the shortcuts' properties 
and set "Run" to "minimized."
The batch files accept a "/?" option to show their usage, and
the scripts accept "-h":
C:\TECS\projects\09>JackCompiler /?
Usage:
    JackCompiler              Compiles all .jack files in the current
                              working directory.
    JackCompiler DIRECTORY    Compiles all .jack files in DIRECTORY.
    JackCompiler FILE.jack    Compiles FILE.jack to FILE.vm.
From the command line, typing "Assembler" will start the assembler in 
interactive mode.  Typing "Assembler xxx.asm" will assemble xxx.asm generating 
xxx.hack.  There is no way to automatically compare to expected output.  You 
can automate this compare using the TextComparer tool.
 Successful assembly:
C:\TECS\projects\04\fill>Assembler Fill.asm
Assembling "c:\TECS\projects\04\fill\Fill.asm"
 Failed assembly: 
C:\TECS\projects\04\fill>Assembler Fill.asm
Assembling "C:\TECS\projects\04\fill\Fill.asm"
In line 15, Expression expected
From the command line, typing "HardwareSimulator" will run start the simulator 
in interactive mode.  Typing "HardwareSimulator xxx.tst" will run the test 
script in the simulator and report the result.
 Successful test:
C:\TECS\projects\02>HardwareSimulator ALU.tst
End of script - Comparison ended successfully
 Failed test:
C:\TECS\projects\02>HardwareSimulator ALU.tst
Comparison failure at line 24
 Error in associated HDL file:
C:\TECS\projects\02>HardwareSimulator ALU.tst
In HDL file C:\TECS\projects\02\ALU.hdl, Line 60, out[16]: the specified sub 
bus is not in the bus range: load ALU.hdl
CPUEmulator and VMEmulator work similarly, either opening the emulator in 
interactive mode if there is no parameter, or running a test script.
With no arguments, "JackCompiler" will compile all files in the current 
directory. With an argument, it will compiler a single Jack file or all 
the files in the named directory. More than one argument is not supported.  
Wildcards are not supported.
 Compile current directory:
C:\TECS\projects\09\Reflect>JackCompiler
Compiling "c:\TECS\projects\09\Reflect"
 Compile single file:
C:\TECS\projects\09\Reflect>JackCompiler Mirrors.jack
Compiling "C:\TECS\projects\09\Reflect\Mirrors.jack"
 Compile "Reflect" directory:
C:\TECS\projects\09>JackCompiler Reflect
Compiling "C:\TECS\projects\09\Reflect"
TextComparer takes two files to compare and reports success or failure:
C:\TECS\projects\02>HardwareSimulator ALU.tst
Comparison failure at line 24
C:\TECS\projects\02>TextComparer ALU.cmp ALU.out
Comparison failure in line 23:
|0101101110100000|0001111011010010|1|1|0|0|0|0|0001111011010010|0|0|
|0101101110100000|0001111011010010|1|1|0|0|0|0|0001111011010010|0|1|
[Note line number discrepancy.]
The tools do not do sensible things with exit codes. If you use them in 
automated testing you will need to capture and parse their output.
 
[1] Why hard links don't work: The class and jar files for the Nand2Tetris 
tools are stored in subdirectories under the 
nand2tetris/tools directory.  
The command that starts the tools needs to tell Java where these 
files are located, and it uses relative paths to do so.  The script looks at 
$0 (argument 0 it the command's file path) and changes to that 
directory before running the Java command.
If you put a hard link from ~/bin/Xxx to ~/nand2tetris/tools/Xxx.sh 
then $0 will say ~/bin/Xxx so that is where the scrip will be 
looking for the required subdirectories.
If you use a symbolic link, the script can test for that and follow the link to get 
to the correct directory where Xxx.sh and the Java files are stored.