Compile Scala class files from the command line (a Scalac shell script that includes jar file dependencies)

I took a couple of hours to write some Scala scripts to email me some Twitter information a couple of times a day, and while creating those scripts I created a simple Linux shell script to compile my Scala classes, while also including my library dependencies. Here's the Linux shell script I created and named


for i in `ls ../lib/*.jar`

# compile all the scala class files in the current directory,
# putting my jar file dependencies on the classpath, and writing
# the ".class" files as output to the ../bin directory:
scalac -classpath "$THE_CLASSPATH" \
       -d ../bin \

Note that this script does several things:

  • Includes the jar files I have in my ../lib subdirectory by putting them in my classpath.
  • Compiles the output to my ../bin directory by using the -d option of the scalac command.