4 Steps to Setup Scala On CentOS

Scala is a widely used Functional Programming language in today’s era of programming. It is a hybrid language which combines the feature of functional and object oriented programming together. Same as Java it also convert the source code to byte code hence it require JVM in order to execute the program. You can learn more about it from this link.

The Setup of Scala on CentOS can be done as the same way as Java which is explained already in article 2 Ways of installing Java 8 on CentOS.

So let’s begin with the installation after logging in with root user…..!!!!!

Step 1: Download Tarball OR RPM file of Scala 2.11.6 using below commands

$ cd /data
$ wget http://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.tgz

OR

$ wget http://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.rpm

Step 2: Installation

For Tarball Install, extract .tgz file under /opt directory and move scala-2.11.6 to /opt/scala directory

$ cp /data/scala-2.11.6.tgz /opt/
$ cd /opt/
$ tar -xvf scala-2.11.6.tgz
$ mv scala-2.11.6 scala
$ rm -f scala-2.11.6.tgz

For RPM Install,
Extract scala RPM file

$ rpm -ivh /data/scala-2.11.6.rpm

Step 3: Configure scala, scalac, scaladoc and scalap commands using alternatives (in case you have done tarball installation)

$ alternatives --install /usr/bin/scala scala /opt/scala/bin/scala 2 
$ alternatives --install /usr/bin/scalac scalac /opt/scala/bin/scalac 2 
$ alternatives --install /usr/bin/scaladoc scaladoc /opt/scala/bin/scaladoc 2 
$ alternatives --install /usr/bin/scalap scalap /opt/scala/bin/scalap 2

No need to use alternatives command if installation is done using rpm.

Check Scala version

$ scala -version

Scala code runner version 2.11.6 — Copyright 2002-2013, LAMP/EPFL

Step 4: Update SCALA_HOME for all users in any of below files

Update /etc/profile (Global for all users)

echo "" >> /etc/profile
echo "## Setting SCALA_HOME for all USERS ##" >> /etc/profile
echo "export SCALA_HOME=/opt/scala" >> /etc/profile
source /etc/profile

Same thing can be done in ~/.bash_profile for user specific installation.
So finally done with Scala installation…..!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>