Scala Environment Setup

Advertisements


The Scala language can be installed on any UNIX-like or Windows system. Before you start installing Scala on your machine, you must have Java 1.5 or greater installed on your computer.

Installing Scala on Windows:

Step (1): JAVA Setup:

First, you must set the JAVA_HOME environment variable and add the JDK's bin directory to your PATH variable. To verify if everything is fine, at command prompt, type java -version and press Enter. You should see something like the following:

C:\>java -version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02, mixed mode)

C:\>

Next, test to see that the Java compiler is installed. Type javac -version. You should see something like the following:

C:\>javac -version
javac 1.6.0_15

C:\>

Step (2): Scala Setup:

Next, you can download Scala from http://www.scala-lang.org/downloads. At the time of writing this tutorial I downloaded scala-2.9.0.1-installer.jar and put it in C:/> directory. Make sure you have admin privilege to proceed. Now execute the following command at command prompt:

C:\>java -jar scala-2.9.0.1-installer.jar

C:\>

Above command will display an installation wizard, which will guide you to install scala on your windows machine. During installation, it will ask for license agreement, simply accept it and further it will ask a path where scala will be installed. I selected default given path C:\Program Files\scala, you can select a suitable path as per your convenience. Finally, open a new command prompt and type scala -version and press Enter. You should see the following:

C:\>scala -version
Scala code runner version 2.9.0.1 -- Copyright 2002-2011, LAMP/EPFL

C:\>

Congratulations, you have installed Scala on your Windows machine. Next section will teach you how to install scala on your Mac OS X and Unix/Linux machines.

Installing Scala on Mac OS X and Linux

Step (1): JAVA Setup:

Make sure you have got the Java JDK 1.5 or greater installed on your computer and set JAVA_HOME environment variable and add the JDK's bin directory to your PATH variable. To verify if everything is fine, at command prompt, type java -version and press Enter. You should see something like the following:

$java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Server VM (build 1.5.0_22-b03, mixed mode)
$

Next, test to see that the Java compiler is installed. Type javac -version. You should see something like the following:

$javac -version
javac 1.5.0_22
javac: no source files
Usage: javac <options> <source files>
................................................

$

Step (2): Scala Setup:

Next, you can download Scala from http://www.scala-lang.org/downloads. At the time of writing this tutorial I downloaded scala-2.9.0.1-installer.jar and put it in /tmp directory. Make sure you have admin privilege to proceed. Now, execute the following command at command prompt:

$java -jar scala-2.9.0.1-installer.jar
Welcome to the installation of scala 2.9.0.1!
The homepage is at: http://scala-lang.org/
press 1 to continue, 2 to quit, 3 to redisplay
1
................................................
[ Starting to unpack ]
[ Processing package: Software Package Installation (1/1) ]
[ Unpacking finished ]
[ Console installation done ]

$

During installation, it will ask for license agreement, to accept it type 1 and it will ask a path where scala will be installed. I entered /usr/local/share, you can select a suitable path as per your convenience. Finally, open a new command prompt and type scala -version and press Enter. You should see the following:

$scala -version
Scala code runner version 2.9.0.1 -- Copyright 2002-2011, LAMP/EPFL

$

Congratulations, you have installed Scala on your UNIX/Linux machine.



Advertisements
Advertisements