How To Install Scala 3 on RHEL 8 / CentOS 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"

Scala combines object-oriented and functional programming in one concise, high-level language. Scala’s static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries. So, you will learn how to install Scala 3 on RHEL 8 / CentOS 8

It is a strong statically typed general-purpose programming language which supports both object-oriented programming and functional programming

Installing Scala means installing various command-line tools such as the Scala compiler and build tools. In this tutorial we will use the Scala installer tool “Coursier” that automatically installs all the requirements, but you can still manually install each tool.

Coursier is a Maven/Ivy-style dependency resolver/fetcher that has been completely rewritten in Scala. It aspires to be quick and simple to integrate into various environments. Functional programming principles are at the heart of it. It’s main command is cs.

Install using the following command (curl)

curl -fLo cs"$(uname | tr LD ld)"

Add the following commands to setup the installation requisites

sudo chmod +x cs

The Scala installer is a tool named Coursier, whose main command is named cs. It ensures that a JVM and standard Scala tools are installed on your system. Install it on your system with the following instructions.

Run the following command to start the installation

./cs install cs

Export the path to the ~/.bashrc file & source it

export PATH="$PATH:/home/scala/.local/share/coursier/bin"
source ~/.bashrc

Now setup the CS using the following command

./cs setup

It might take a while to complete

Now install scala3 with the cs

cs install scala3

After installing necessary file, you are done installing scala3

Check it using the following command

scala3 -version

Let’s test out some code !

create a file names unixcop.scala & add the following lines to that file

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

This will print out a simple hello output to the console

After saving it, run this scalac command at your command line prompt to compile it:

scalac is just like javac, and that command creates two new files

unixcop$.class & unixcop.class

These are the same types of “.class” bytecode files you create with javac, and they’re ready to work with the JVM.

Now you can run the Hello application with the scala command:

This will print out this message to the console

"Hello, UnixCop !"
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"
Unix/Linux Guru and FOSS supporter


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook