Scala – Setup

  • Post category:Scala
  • Reading time:6 mins read

Scala Setup – Linux

Scala can be installed on any UNIX flavored or Windows based system. Before you start installing Scala on your machine, you must have Java 1.8 or greater installed on your computer.

Follow the steps given below to install Scala.

Verify Java Installation

Verify If Java is installed on machine or not.

Verify the JDK installation on your machine. Open terminal and type java -version and javac -version.

$ javac -version
javac 1.8.0_20

$ java -version 
java version "1.8.0_20" 
Java(TM) SE Runtime Environment (build 1.8.0_20-b26) 
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) 

NOTE: We assume that the readers of this tutorial have Java 8 installed in their system. In case you do not have Java SDK, download its current version from http://www.oracle.com/technetwork/java/javase/downloads/index.html and install it.

Download and install Scala

Download Scala Binaries from https://www.scala-lang.org/download/. Download the tar file and untar the same to a location

$ tar -xf file_name.tar -C /target/directory 
$ tar -xf file_name.tar.gz --directory /target/directory

Example
$ tar -xvzf scala-2.11.6.tgz -C ~/Proedu/

Now go to the directory where you have extracted the scala distribution. Go to the bin directory and start Scala shell as mentioned below.

$ cd ~/Proedu/scala-2.11.6 
[proedu@local scala-2.11.6]$cd bin
[proedu@local bin]$ ./scala 

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel 
Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_20). 
Type in expressions to have them evaluated. Type :help for more information. 
scala>

Scala Setup – Windows

Verify Java Installation

Verify If Java is installed on machine or not.

Verify the JDK installation on your machine. Open terminal and type java -version and javac -version.

Download and install Scala

Download Scala 2.11.7 binaries in the system from  http://www.scala-lang.org/download/ . Run the downloaded file and just follow the subsequent steps.

scala installation1

scala installation2

scala installation3

scala installation4

scala installation5

scala installation6

scala installation7

Finally Click on finish button

Set path in environment variable

Right-click on My Computer -> Properties -> Advanced System setting ->Environment Variable -> Select Path -> Edit and add the path as mentioned below

C:\Program Files\scala\bin;
NOTE: Considering we have installed Scala at location C:\Program Files\scala

To validate, open a command prompt and type Scala. You should be able to see Scala prompt.