Building Scala 2.x - linux-on-ibm-z/docs GitHub Wiki
Building Scala
ATTENTION!!! This package uses Log4j. Please see details here, for the updates on security vulnerabilities.
Below versions of Scala are available in respective distributions at the time of creation of these build instructions:
- Ubuntu (18.04, 20.04, 20.10) has
2.11.12-4
- RHEL (8.1, 8.2, 8.3) has
2.10.6
The instructions provided below specify the steps to build Scala version 2.13.3 on Linux on IBM Z Systems for following distributions:
- RHEL (7.8, 7.9, 8.1, 8.2, 8.3)
- SLES (12 SP5, 15 SP1, 15 SP2)
- Ubuntu (18.04, 20.04, 20.10)
General Notes:
- When following the steps below please use a standard permission user unless otherwise specified.
- A directory
/<source_root>/
will be referred to in these instructions. This is a temporary writable directory anywhere you'd like to place it.
Step 1: Build and Install Scala
1.1) Install the dependencies
export SOURCE_ROOT=/<source_root>/
-
RHEL (7.8, 7.9, 8.1, 8.2, 8.3)
-
With OpenJDK
sudo yum install -y java-11-openjdk java-11-openjdk-devel wget
-
With AdoptOpenJDK
sudo yum install -y tar wget
- Download and install AdoptOpenJDK 11 (with HotSpot or with OpenJ9) from here.
-
-
SLES (12 SP5, 15 SP1, 15 SP2)
-
With OpenJDK
sudo zypper install -y java-11-openjdk java-11-openjdk-devel wget
-
With AdoptOpenJDK
sudo zypper install -y tar wget gzip
- Download and install AdoptOpenJDK 11 (with HotSpot or with OpenJ9) from here.
-
-
Ubuntu (18.04, 20.04, 20.10)
-
With OpenJDK
sudo apt-get update sudo apt-get install -y wget openjdk-11-jdk openjdk-11-jdk-headless
-
With AdoptOpenJDK
sudo apt-get update sudo apt-get install -y wget tar gzip
- Download and install AdoptOpenJDK 11 (with HotSpot or with OpenJ9) from here.
-
1.2) Set Environment Variables
export JAVA_HOME=<Path to Java>
export PATH=$JAVA_HOME/bin:$PATH
1.3) Download and Install Scala
-
For RHEL and SLES
cd $SOURCE_ROOT wget http://www.scala-lang.org/files/archive/scala-2.13.3.rpm sudo rpm -ivh scala-2.13.3.rpm
-
For Ubuntu
cd $SOURCE_ROOT wget http://www.scala-lang.org/files/archive/scala-2.13.3.deb sudo dpkg -i scala-2.13.3.deb
Check Scala version by using the following command
scala -version
scalac -version
Scala code runner version 2.13.3 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc.
Scala compiler version 2.13.3 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc.
Step 2: [Optional] Testing Scala Sample Program
2.1) Create at test program
Create a test file called HelloWorld.scala
:
object HelloWorld
{
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
2.2) Compile the test program
scalac HelloWorld.scala
Note: This will create two compiled files: HelloWorld$.class
and HelloWorld.class
.
2.3) Execute the test program
scala HelloWorld
The output of the above test program should be:
Hello, world!
Note: For addition information on Getting Started with Scala, visit here.