DebianDebian Based

How To Install Scala on Debian 12

Install Scala on Debian 12

In this tutorial, we will show you how to install Scala on Debian 12. Scala, a high-level, statically typed programming language, has been gaining popularity due to its seamless integration with Java and its functional programming capabilities. It combines the best of both worlds: the object-oriented model of Java and the power of functional programming, making it a versatile choice for developers.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Scala programming language on a Debian 12 (Bookworm).


  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You will need an active internet connection to download the Scala package.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Scala on Debian 12 Bookworm

Step 1. Keeping your system up-to-date is a fundamental practice in maintaining a secure and efficient operating environment. It ensures that you have the latest features, security patches, and software compatibility. To update your Debian 12 system, execute the following command in your terminal:

sudo apt update
sudo apt upgrade

This command first updates the list of available packages and their versions then upgrades the installed packages to their latest versions.

Step 2. Installing Java.

Before we dive into the installation process, it’s crucial to ensure that Java is installed on your system. Scala runs on the Java Virtual Machine (JVM), so having Java installed is a prerequisite. You can verify the installation by typing the following command in your terminal:

java -version

If Java is installed, the command will return the version of Java currently in use. If not, you’ll need to install it. You can do so by running:

sudo apt update
sudo apt install default-jdk

Step 3. Installing Scala on Debian 12.

Coursier is a tool that simplifies the installation of Scala. To install Coursier, use the following commands:

curl -fLo cs
chmod +x cs
./cs setup

After installing Coursier, you can install Scala by running:

cs install scala

Once the installation is complete, you can verify it by checking the Scala version. Run the following command:

scala -version

If Scala is installed correctly, the command will return the version of Scala currently in use.

Step 4. Set Up a Scala Project.

Now that Scala is installed, let’s create a new Scala project. We’ll use sbt (Scala Build Tool), a build tool specifically designed for Scala projects. To create a new project, run:

cs install sbt

Then, create a new project:

sbt new scala/scala-seed.g8

This command will prompt you to name your project. The project structure will include a build.sbt file, which defines the project settings.

Step 5. Write a Simple Scala Program.

Let’s write a simple “Hello World” program in Scala. In your project directory, navigate to src/main/scala and create a new file named HelloWorld.scala. Add the following code:

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, world!")

To compile and run the program, use sbt:

sbt run

Congratulations! You have successfully installed Scala. Thanks for using this tutorial to install the latest version of the Scala programming language on Debian 12 Bookworm. For additional help or useful information, we recommend you check the official Scala website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button