How to install sbt on Ubuntu For Scala and Java projects

Looking to work with Scala or Java on Linux? If so, you'll want the Scala Build Tool up and running.

How to install sbt on Ubuntu For Scala and Java projects

Scala is a general-purpose, object-oriented programming language that is influenced by Java. In fact, Scala projects can be coded in the same way as Java projects. As well, a number of Java libraries (as well as other, third-party libraries) can be used within Scala.

Since Scala is in high demand for data processing and distributed programming, it is a language you might want to have in your toolkit. 

But if your development platform is Linux, you won't be able to work with Scala out of the box. To remedy that, you need the help of a cross-platform build tool, like sbt. Sbt (Scala Build Tool) offers native support for compiling Scala code and integrates with Scala test frameworks. 

SEE: Telephone interview cheat sheet: Software developer (TechRepublic Premium)

I'm going to walk you through the process of installing the necessary components to start working with sbt. I'll demonstrate on Ubuntu 19.04, but the tools can be installed on other distributions.

What you need

To make this happen, you need a working instance of Ubuntu Desktop 19.04, and a user account with sudo access. With those bits at the ready, let's get to work.

Installing Java

The first thing to do is install Java. In order to do that, we'll install the default JDK package. First update and upgrade Ubuntu with the commands:

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

When this process completes, if necessary reboot the machine.

Install the default JDK with the command:

sudo apt-get install default-jdk -y

Install Scala

Next we'll install Scala. To do this, download the necessary .deb file with the command:


Note: Check the Scala archive page to make sure you're downloading the latest version of Scala. 

With the Scala .deb file downloaded, install it with the command:

sudo dpkg -i scala*.deb

When that installation finishes, type the command scala to enter the scala prompt (to be certain the installation was successful - Figure A).


Figure A: The Scala installation was a rousing success.

Exit the scala prompt with the command :quit.

Install SBT

Now it's time to install sbt. First add the necessary repository with the command:

echo "deb /" | 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:// --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

This should report that a project definition is loaded (it's empty, of course) and should end with success (Figure B).


Figure B: Sbt is successfully installed.

Ready and waiting

And that's all there is to it. Sbt is now ready and waiting for you to build your first project. For more information on getting started with developing on sbt, check out the official sbt reference manual.

Also see


Jack Wallen