How To Install Scala on Ubuntu 22.04

In this article we will learn how to install Scala on Ubuntu 22.04 operating system.


Scala, a powerful and versatile programming language, has gained popularity in recent years for its unique blend of functional and object-oriented programming paradigms. Developed by Martin Odersky and first released in 2003, Scala has evolved into a language that combines the best of both worlds, offering a scalable and expressive platform for building robust and efficient applications. In this article, we will delve into the world of Scala, exploring its key features, advantages, and use cases.

Functional and Object-Oriented Paradigms

Scala stands out for its ability to seamlessly integrate both functional and object-oriented programming styles. This duality allows developers to leverage the strengths of both paradigms, resulting in code that is not only expressive but also highly modular and maintainable.

Functional programming in Scala is achieved through the use of first-class functions, immutable data structures, and pattern matching. This enables developers to write code that is concise and easy to reason about, making it well-suited for tasks such as data processing, concurrent programming, and complex algorithms.

On the object-oriented side, Scala provides support for classes, objects, and inheritance, making it easy to create reusable and extensible code. The language also emphasizes the use of traits, which are similar to interfaces in Java but offer a more powerful and flexible mechanism for code composition.

How To Install Scala On Ubuntu 22.04

To install Scala programming language on Ubuntu 22.04, there are several steps as described below :

1. Ensure the system packages are up-to-date
2. Verify if the system has Java installed
3. Install Scala on Ubuntu 22.04
4. Creating Simple Scala Project

Step 1: Update Package System

To install new packages in the system, we need to ensure if our system is up-to-date, for this purpose we will submit the following command line :

$ sudo apt update
$ sudo apt ugrade
$ sudo apt install wget apt-transport-https gnupg2 software-properties-common

Step 2: Verify if the system has Java installed

Scala programming language requires Java installed on the system, at this point we will verify if our system has already java by submitting command line :

$ java --version

Output :

ramansah@bckinfo:~$ java --version
openjdk 2023-08-24
OpenJDK Runtime Environment (build
OpenJDK 64-Bit Server VM (build, mixed mode, sharing)

If Java is not installed, we can install it by running the following command:

$ sudo apt install default-jdk

Step 3: Install Scala on Ubuntu 22.04

After all are set, then we will install Scala on Ubuntu 22.04 by submitting command line :

$ sudo apt install scala

Output :

ramansah@bckinfo:~$ sudo apt install scala
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libhawtjni-runtime-java libjansi-java libjansi-native-java libjline2-java scala-library
scala-parser-combinators scala-xml
Suggested packages:
The following NEW packages will be installed:
libhawtjni-runtime-java libjansi-java libjansi-native-java libjline2-java scala scala-library
scala-parser-combinators scala-xml
0 upgraded, 8 newly installed, 0 to remove and 188 not upgraded.
Need to get 25,1 MB of archives.
After this operation, 28,6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 jammy/universe amd64 libhawtjni-runtime-java all 1.17-1 [28,8 kB]
Get:2 jammy/universe amd64 libjansi-native-java all 1.8-1 [23,8 kB]
Get:3 jammy/universe amd64 libjansi-java all 1.18-1 [56,8 kB]
Get:4 jammy/universe amd64 libjline2-java all 2.14.6-4 [150 kB]
Get:5 jammy/universe amd64 scala-library all 2.11.12-5 [9.586 kB]
Get:6 jammy/universe amd64 scala-parser-combinators all 1.0.3-3.1 [365 kB]
Get:7 jammy/universe amd64 scala-xml all 1.0.3-3.1 [615 kB]
Get:8 jammy/universe amd64 scala all 2.11.12-5 [14,2 MB]
Fetched 25,1 MB in 11s (2.221 kB/s) 
Selecting previously unselected package libhawtjni-runtime-java.
(Reading database ... 286621 files and directories currently installed.)
Preparing to unpack .../0-libhawtjni-runtime-java_1.17-1_all.deb ...
Unpacking libhawtjni-runtime-java (1.17-1) ...
Selecting previously unselected package libjansi-native-java.
Preparing to unpack .../1-libjansi-native-java_1.8-1_all.deb ...
Unpacking libjansi-native-java (1.8-1) ...
Selecting previously unselected package libjansi-java.
Preparing to unpack .../2-libjansi-java_1.18-1_all.deb ...
Unpacking libjansi-java (1.18-1) ...
Selecting previously unselected package libjline2-java.
Preparing to unpack .../3-libjline2-java_2.14.6-4_all.deb ...
Unpacking libjline2-java (2.14.6-4) ...
Selecting previously unselected package scala-library.
Preparing to unpack .../4-scala-library_2.11.12-5_all.deb ...
Unpacking scala-library (2.11.12-5) ...
Selecting previously unselected package scala-parser-combinators.
Preparing to unpack .../5-scala-parser-combinators_1.0.3-3.1_all.deb ...
Unpacking scala-parser-combinators (1.0.3-3.1) ...
Selecting previously unselected package scala-xml.
Preparing to unpack .../6-scala-xml_1.0.3-3.1_all.deb ...
Unpacking scala-xml (1.0.3-3.1) ...
Selecting previously unselected package scala.
Preparing to unpack .../7-scala_2.11.12-5_all.deb ...
Unpacking scala (2.11.12-5) ...
Setting up scala-library (2.11.12-5) ...
Setting up scala-xml (1.0.3-3.1) ...
Setting up scala-parser-combinators (1.0.3-3.1) ...
Setting up libhawtjni-runtime-java (1.17-1) ...
Setting up libjansi-native-java (1.8-1) ...
Setting up libjansi-java (1.18-1) ...
Setting up libjline2-java (2.14.6-4) ...
Setting up scala (2.11.12-5) ...
update-alternatives: using /usr/share/scala-2.11/bin/scala to provide /usr/bin/scala (scala) in auto mode

Then verity its version by submitting command line :

$ scala -version

Output :

ramansah@bckinfo:~$ scala -version
Scala code runner version 2.11.12 -- Copyright 2002-2017, LAMP/EPFL

Install Scala on Ubuntu 22.04


Step 4 : Creating Simple Scala Project

At this step, we will create a simple Scala project to prove if the Scala programming language is installed and run properly on our system. We will create a simple scala file. we will create a file : helloworld.scala file.

object Ramans
     // Main Method
    def main(args: Array[String])
       // prints Hello World
       println("Hello World!")


creating scala file

then run by submitting command line :

Scala programming



Scala is a versatile and expressive programming language that combines the best of functional and object-oriented paradigms. Its support for concurrency, scalability, and integration with the JVM make it a top choice for building a wide range of applications, from web services and microservices to big data processing and data science. In this article we have discussed Scala installation and create a simple project.


(Visited 88 times, 1 visits today)

Leave a Reply

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