The following Scala installation steps are tested on my CrunchBang Linux 11 “Waldorf” machine.
- Java Environment Check:
Scala requires the Java runtime version 1.6 or later. So before you install Scala, first make sure that you Java environment is set up correctly.-
To test your Java runtime environment, type
java -versionat your command prompt and press ENTER. If your Java environment is set up correctly, you should see something like the following:~$ java -version OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-2~deb7u1) OpenJDK Client VM (build 24.65-b04, mixed mode, sharing) -
Test to see that the Java compiler is properly installed. Type
javac -version. You should see the compiler version if the compiler is found.~$ javac -version javac 1.7.0_65
-
To test your Java runtime environment, type
- Scala Setup:
- Download Scala from www.scala-lang.org/download. The version I downloaded is Scala 2.11.4. You can get the binaries in
tgz,deb,rpm,msi, orzipformat depending on your preference and platform. I had chosen thetgzformat for my installation. - Unarchive the Scala binaries to a directory of your choice. I unachrive the downloaded file in my local
bindirectory.~$ cd ~/bin ~/bin$ tar -zxvf ~/share/downloads/scala-2.11.4.tgz
At this point, you can Start the Scala interpreter (aka the “REPL”) by launching
scalafrom where it was unarchived, or tart the Scala compiler by launchingscalacfrom the same location. - Set Path and Environment. For quick access, add
scalaandscalacto your path. I do so by adding the following lines to the end of my~/.bashrcfile.export SCALA_HOME=~/bin/scala-2.11.4 export PATH=$PATH:$SCALA_HOME/bin
After this either open a new terminal window to activate the two new environmental variables, or reload your
~/.bashrcscript withsource ~/.bashrc
- Download Scala from www.scala-lang.org/download. The version I downloaded is Scala 2.11.4. You can get the binaries in
- Test Your Scala Installation:
Typescala -version, andscalac -versionat the command prompt to test your Scala environment. You should see something like the following:~$ scala -version Scala code runner version 2.11.4 -- Copyright 2002-2013, LAMP/EPFL ~$ scalac -version Scala compiler version 2.11.4 -- Copyright 2002-2013, LAMP/EPFL
- Let’s try a simple command in the REPL. Invoke the REPL by typing
scala, and enter theprintlncommand to say hello to your Scala installation. You can enter:helpto find out more about the commands available in the REPL. Type in:qto quit the REPL when you are done.~$ scala Welcome to Scala version 2.11.4 (OpenJDK Client VM, Java 1.7.0_65). Type in expressions to have them evaluated. Type :help for more information. scala> println("Hello, Scala!") Hello, Scala! scala> :q ~$