Scala

5 / 53

Scala - Installation on your own machine

Note: You can skip this page if you are okay with using CloudxLab environment. Instructions below are for installing Scala on your PC.

Since Scala code is compiled to Java Bytecodes, Scala installation requires Java Software Development Kit (SDK) installed on the machine.

On CloudxLab, Scala is already installed and readily available in the right-hand side frame. The right-hand side frame is essentially Jupyter which is an online environment for programming, analytics and machine learning.

If you want to use scala elsewhere you might have to go for the installation as outlined below.

Java Installation

  • Download Java SDK from Oracle Download Page
  • Install the java using the downloader
  • Check if Java is installed using command java –version in terminal

Set Your Java Environment

Here, java-current is the directory where java is installed

export JAVA_HOME=/usr/local/java-current

Add java to the path

export PATH=$PATH:$JAVA_HOME/bin/

Install Scala

Download Scala from http://www.scala-lang.org/downloads. The version downloaded file will look like - scala-.tgz and it is downloaded to ~/Downloads While writing this tutorial scala-2.12.7.tgz was the latest available source. Please change the version numbers in case you use a different one.

Unpack Scala binary

cd ~/Downloads
tar -xvf scala-2.12.7.tgz
sudo mv scala-2.12.7 /usr/local/
sudo chmod -R 755 /usr/local/scala-2.12.7/bin
export SCALA_HOME=/usr/local/scala-2.12.7/
export PATH=$PATH:$SCALA_HOME/bin

Add the last 2 lines from above in .profile or .bash_profile to set the paths permanently.

Now run, scala command and you should get scala prompt.

$ scala
Welcome to Scala 2.12.7 (OpenJDK 64-Bit Server VM, Java 10.0.2).
Type in expressions for evaluation. Or try :help.

scala> print("Hello");
Hello
scala>

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...