Install Scala on Rocky Linux

Rocky Linux installs the JDK from the distribution's repositories and scala-cli from its installer. The JDK package is the one piece that matters: the Scala compiler runs on it, and sbt and every test framework of the course share it. This is the Rocky Linux page of the install overview, and its commands are shown and not run here, because they install on Rocky Linux and need the network.

The JDK

dnf installs the development package, which carries javac and the headers, not only the runtime:

sudo dnf install -y java-21-openjdk-devel curl

not run in this environment

Rocky 9 ships Java 21 in its application stream, and sudo alternatives --config java picks the release when more than one is installed. JAVA_HOME is not set by the package; a shell profile sets it for the tools that read it.

scala-cli

curl -sSLf https://scala-cli.virtuslab.org/get | sh

not run in this environment

The installer needs curl and gzip, both part of a minimal install; it puts the launcher under the home folder and prints the line to add to the profile. A system-wide install moves that file to /usr/local/bin and needs no profile change.

Check the version

java -version
scala-cli version

not run in this environment

On a minimal server image the first command may print the runtime of a JRE that was already there: openjdk version without a javac is the sign that the -devel package is missing, and the compiler will fail at the first build rather than at the install.

Related

Article author: Arthur Isaev