How to install SBT on ubuntu for building Scala projects

  • Post category:Big Data
  • Reading time:3 mins read

In this post, I’m going to walk you through the process of installing SBT on Ubuntu machine. SBT is an open-source build tool for Scala and Java projects, similar to Java’s Maven and Ant.

STEPS:

Update and Upgrade Ubuntu

Lets first update and upgrade Ubuntu with the commands shown below

sudo apt-get update
sudo apt-get upgrade -y

Installing Java

Install the default JDK with the command:

sudo apt-get install default-jdk -y

Install Scala

Next step is to install Scala. To do this, download the necessary .deb file from Scala archive

wget www.scala-lang.org/files/archive/scala-2.13.1.deb

Then install the downloaded package with the command:

sudo dpkg -i scala*.deb

To make sure scala is installed, type the command scala to enter the scala prompt. To exit scala prompt type command :q or :quit

Install SBT

Now it’s time to install SBT. First add the necessary repository with the command:

echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list

Add the public key for the installation with the command:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823

Update apt with the command:

sudo apt-get update

Finally, install sbt with the command:

sudo apt-get install sbt -y

Once the installation is complete, test to make sure all is working with the command:

sbt test