Get Scala 3 Running on RHEL 8 or CentOS 8 Without the Hassle
If you’ve been hunting for a way to run the new Scala 3 compiler on your enterprise Linux box, you’re in the right place. This guide skips the fluff and gets you from “I have no idea where to start” straight to scala -version showing a shiny 3.x release.
Prerequisites for a smooth install
Before you do anything, make sure your system is up‑to‑date and that you’re not juggling two conflicting JDKs.
1. Update the OS –
sudo dnf update -y
A fresh kernel and updated libraries prevent a cascade of “missing symbol” errors later.
2. Choose your Java version – Scala 3 requires at least OpenJDK 17. If you already have JDK 8 or 11, it’s time to retire them (or at least stop mixing them).
sudo dnf install java-17-openjdk-devel -y
Scala 3 uses the new Java language features and the class file format introduced in 17.
Getting your environment ready
Now that you have a compatible JDK, set up a clean place for Scala to live.
1. Create a dedicated directory –
sudo mkdir -p /opt/scala3
Keeping third‑party tools out of /usr/local keeps the system tidy and makes future upgrades painless.
2. Download the latest release – Pull it straight from the official distribution site.
cd /tmp && curl -LO https://downloads.lightbend.com/scala/3.3.1/scala-3.3.1.tgz
The tarball is the most reliable way to get a consistent build; package managers sometimes lag.
3. Extract it –
sudo tar -xzf scala-3.3.1.tgz -C /opt/scala3 --strip-components=1
--strip-components=1 removes the top‑level folder so you don’t end up with /opt/scala3/scala-3.3.1/....
Wire it into your shell
Finally, make sure your shell knows where to find the compiler and libraries.
echo 'export SCALA_HOME=/opt/scala3' | sudo tee /etc/profile.d/scala3.sh echo 'export PATH=$SCALA_HOME/bin:$PATH' | sudo tee -a /etc/profile.d/scala3.sh
Reload the profile or log out/in:
source /etc/profile.d/scala3.sh
Verify everything works
Run a quick sanity check:
scala -version # => Scala 3.3.1 (OpenJDK Java 17)
If that line prints, you’re good to go.
> I once had a colleague upgrade the JDK from 8 to 11 on a RHEL 8 server, and all his Scala 2.13 projects started throwing scala/Predef$ errors because the new compiler silently pulled in Java 9 modules. The lesson? Keep your Java version explicit and match it with the Scala release.
Alternative: SDKMAN! (but only if you need multiple versions)
If you’re a hobbyist who likes to experiment with different Scala releases, SDKMAN! is a handy wrapper. Install it once:
curl -s "https://get.sdkman.io" | bash source "$HOME/.sdkman/bin/sdkman-init.sh"
Then install Scala 3:
sdk install scala 3.3.1
SDKMAN! will handle the $SCALA_HOME and PATH for you, but it adds another layer of indirection. If your only goal is a single, stable compiler on a production box, stick with the manual method above.
That’s all there is to it—no fancy containers or hidden dependencies. Drop a quick scala -version after reboot and you’ll know everything’s wired up correctly. Enjoy building those first‑class functions and pattern matchers in Scala 3!