Install Scala

This is a step-by-step guide to install Scala on Mac

Pavan Kulkarni

2 minute read

Install Scala on Mac system easily and quickly. This post will give a complete walk through of installing Scala using brew and manual process.

Wikipedia quotes Scala as “Scala is a general-purpose programming language providing support for functional programming and a strong static type system. Designed to be concise, many of Scala’s design decisions aimed to address criticisms of Java.”

Personally I have found Scala to be a strong programming language for its concise coding structure.

Scala runs on JVM. Hence Java is mandatory for this installation. Check here to Install Java.

Once you have Java up and running, run the below commands to install Scala

Installing Scala with brew

Installing Scala on Mac using brew is a simple process. You need to have brew installed on your system as a pre-requisite. You can install brew from here

$ brew update
$ brew install scala
$ brew install sbt

To verify installation, type scala in your terminal. This should give a scala prompt.

Pavans-MacBook-Pro:~ pavanpkulkarni$ scala
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_152).
Type in expressions for evaluation. Or try :help.

scala>

brew installs Scala in the location /usr/local/Cellar/scala/

Installing Scala manually.

  1. Download the latest release of Scala from the official website. This is usually the scala-x.x.x.tgz for Mac.
  2. Unzip the file to /usr/local/bin/
    • tar xf scala-x.x.x.tgz -C /usr/local/bin/
  3. Add SCALA_HOME entry in your .bash_profile

    #Scala Home
    export SCALA_HOME=/usr/local/bin/scala
    export PATH=$PATH:$SCALA_HOME/bin
    
  4. Verify scala installation by running scala command in your terminal. If the installation is successful, you will see a scala prompt in the terminal

    Pavans-MacBook-Pro:~ pavanpkulkarni$ scala
    Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_152).
    Type in expressions for evaluation. Or try :help.
    
    scala>
    

References:

  1. https://en.wikipedia.org/wiki/Scala_(programming_language)
  2. https://www.scala-lang.org/download/