How do I install Scala on RHEL 8 / CentOS 8?. Scala is an object-oriented and functional programming language designed to be extremely concise and logical. Scala Programming is based on Java and powers popular applications, such as Spark. If you understand Java syntax, it should be easy to master Scala.

install scala on rhel8

Install Scala on RHEL / CentOS 8 from AppStream repository

Scala for RHEL/CentOS is distributed through AppStream repository.

$ sudo yum module list | grep scala
scala 2.10 [d] default [d] A hybrid functional/object-oriented language for the JVM

Install Scala by running the command below.

$ sudo yum install @scala

Verify Scala installation by checking version.

$ scala -version
Scala code runner version 2.10.6 -- Copyright 2002-2013, LAMP/EPFL

Install Scala from RPM package

Here are the few steps required to have Scala installed on RHEL / CentOS 8 from an RPM package.

Step 1: Install Java on CentOS 8 / RHEL 8

The first requirement is Java. Ensure you have Java installed on your RHEL 8 / CentOS 8 machine. The following guide should be helpful.

How to Install Java 11 (OpenJDK 11) on RHEL / CentOS 8

Validate installation of Java runtime using the command:

$ java -version
openjdk version "11-ea" 2018-09-25
OpenJDK Runtime Environment (build 11-ea+28)
OpenJDK 64-Bit Server VM (build 11-ea+28, mixed mode, sharing)

Step 2: Install Scala on CentOS 8 / RHEL 8

After Java is installed, proceed to download Scala RPM package and install it on your RHEL 8 machine. First, check for the latest release of Scale on the Downloads page.

export VER="2.13.1"

Replace 2.13.1 with the recent one available on the downloads section.

Install Downloaded package with dnf command.

$ sudo dnf install scala-$VER.rpm
Last metadata expiration check: 0:27:09 ago on Tue 24 Sep 2019 08:26:12 PM EAT.
 Dependencies resolved.
  Package                         Arch                             Version                             Repository                              Size
  scala                           noarch                           2.13.1-1                            @commandline                           116 M
 Transaction Summary
 Upgrade  1 Package
 Total size: 116 M
 Is this ok [y/N]: y
 Downloading Packages:
 Running transaction check
 Transaction check succeeded.
 Running transaction test
 Transaction test succeeded.
 Running transaction
   Preparing        :                                                                                                                           1/1 
   Running scriptlet: scala-2.13.1-1.noarch                                                                                                     1/2 
   Upgrading        : scala-2.13.1-1.noarch                                                                                                     1/2 
   Cleanup          : scala-2.10.6-14.module_el8.0.0+82+8ee6c375.noarch                                                                         2/2 
   Running scriptlet: scala-2.10.6-14.module_el8.0.0+82+8ee6c375.noarch                                                                         2/2 
   Verifying        : scala-2.13.1-1.noarch                                                                                                     1/2 
   Verifying        : scala-2.10.6-14.module_el8.0.0+82+8ee6c375.noarch                                                                         2/2 

Verify Scala installation by checking version.

$ scala -version
Scala code runner version 2.13.1 -- Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.

Test Scala Installation on CentOS 8 / RHEL 8

Try to print “Hello World” in Scala.

$ scala
Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 11-ea).
Type in expressions for evaluation. Or try :help.
scala> println("Hello Scala World")
Hello Scala World
scala> :q

:q is used to quit from Scala shell.

Running Scala as shell script

You can run Scala program as a shell script . Save file below to

  exec scala "$0" "[email protected]"
  object HelloWorld {
    def main(args: Array[String]) {
      println("Hello, Scala World! " + args.toList)

Run the script like below.


Compiling Scala Code

The scalac command is used to compile Scala source file and generate Java bytecode which can be executed on any standard JVM. See example below.

$ cat HelloWorld.scala 
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")

Compile it.

$ scalac HelloWorld.scala

By default scalac generates the class files into the current working directory but you can specify a different output directory using the -d option.

Use scala command to execute the generated bytecode.

$ scala HelloWorld
Hello, world!

That’s all. Enjoy doing Scala Development on RHEL 8 and refer to the Official Documentation for more information.

More reading:

How to Install Zabbix Server on RHEL 8 / CentOS 8

Install and Configure phpMyAdmin on RHEL 8 / CentOS 8

How to Install Apache with mod_ssl & mod_http2 on RHEL 8

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here