{"id":10144,"date":"2026-03-22T23:37:49","date_gmt":"2026-03-22T20:37:49","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=10144"},"modified":"2026-03-22T23:37:50","modified_gmt":"2026-03-22T20:37:50","slug":"install-scala-rhel-ubuntu","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/install-scala-rhel-ubuntu\/","title":{"rendered":"Install Scala on RHEL 10 \/ Ubuntu 24.04"},"content":{"rendered":"\n<p>Scala is a modern programming language that runs on the Java Virtual Machine (JVM). It combines object-oriented and functional programming in a statically typed language, making it a strong choice for building scalable backend services, data pipelines, and distributed systems. Scala powers frameworks like <a href=\"https:\/\/github.com\/apache\/spark\" target=\"_blank\" rel=\"noreferrer noopener\">Apache Spark<\/a>, Akka, and Play Framework.<\/p>\n\n\n\n<p>This guide covers installing Scala 3.8.2 on RHEL 10, Rocky Linux 10, AlmaLinux 10, and Ubuntu 24.04. We walk through two installation methods &#8211; the recommended Coursier approach and manual tarball installation &#8211; plus setting up sbt (Scala Build Tool) and creating your first project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before starting, make sure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A server or workstation running RHEL 10, Rocky Linux 10, AlmaLinux 10, or Ubuntu 24.04<\/li>\n\n<li>Root or sudo access<\/li>\n\n<li>Internet connectivity to download packages<\/li>\n\n<li>Java 11 or later (we install this in Step 1)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install Java (JDK)<\/h2>\n\n\n\n<p>Scala runs on the JVM, so a Java Development Kit is required. OpenJDK 17 or 21 are the best choices for Scala 3.x. If you already have <a href=\"https:\/\/computingforgeeks.com\/install-java-on-rocky-almalinux-9\/\" target=\"_blank\" rel=\"noreferrer noopener\">Java installed<\/a>, skip to Step 2.<\/p>\n\n\n\n<p><strong>On RHEL 10 \/ Rocky Linux 10 \/ AlmaLinux 10:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y java-21-openjdk-devel<\/code><\/pre>\n\n\n\n<p><strong>On Ubuntu 24.04:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y openjdk-21-jdk<\/code><\/pre>\n\n\n\n<p>Confirm that Java is installed and available in your PATH.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<p>The output should show the OpenJDK version you just installed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openjdk version \"21.0.6\" 2025-01-21 LTS\nOpenJDK Runtime Environment (build 21.0.6+7-LTS)\nOpenJDK 64-Bit Server VM (build 21.0.6+7-LTS, mixed mode, sharing)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Scala Using Coursier (Recommended)<\/h2>\n\n\n\n<p>Coursier is the recommended way to install Scala and manage Scala tools. The <code>cs setup<\/code> command installs the Scala compiler, REPL, and related tools in one step. This is the method endorsed by the <a href=\"https:\/\/www.scala-lang.org\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\">official Scala project<\/a>.<\/p>\n\n\n\n<p>Download and run the Coursier installer:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fL \"https:\/\/github.com\/coursier\/coursier\/releases\/latest\/download\/cs-x86_64-pc-linux.gz\" | gzip -d > cs\nchmod +x cs\n.\/cs setup -y<\/code><\/pre>\n\n\n\n<p>The installer adds Scala tools to <code>~\/.local\/share\/coursier\/bin<\/code> and updates your shell profile. Load the new PATH in your current session:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source ~\/.profile<\/code><\/pre>\n\n\n\n<p>Verify that Scala is accessible:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scala -version<\/code><\/pre>\n\n\n\n<p>You should see the Scala 3 version in the output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Scala code runner version 3.8.2 -- Copyright 2002-2026, LAMP\/EPFL<\/code><\/pre>\n\n\n\n<p>You can clean up the downloaded installer file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rm -f cs<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Install Scala Manually from Tarball<\/h2>\n\n\n\n<p>If you prefer a manual installation or need Scala available system-wide for all users, download the official tarball from GitHub releases.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SCALA_VERSION=\"3.8.2\"\nwget https:\/\/github.com\/scala\/scala3\/releases\/download\/${SCALA_VERSION}\/scala3-${SCALA_VERSION}-x86_64-pc-linux.tar.gz<\/code><\/pre>\n\n\n\n<p>Extract the archive to <code>\/usr\/local<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo tar -xzf scala3-${SCALA_VERSION}-x86_64-pc-linux.tar.gz -C \/usr\/local\/\nsudo ln -sf \/usr\/local\/scala3-${SCALA_VERSION}\/bin\/scala \/usr\/local\/bin\/scala\nsudo ln -sf \/usr\/local\/scala3-${SCALA_VERSION}\/bin\/scalac \/usr\/local\/bin\/scalac<\/code><\/pre>\n\n\n\n<p>Verify the installation works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scala -version<\/code><\/pre>\n\n\n\n<p>The version output confirms Scala is installed system-wide:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Scala code runner version 3.8.2 -- Copyright 2002-2026, LAMP\/EPFL<\/code><\/pre>\n\n\n\n<p>Clean up the downloaded archive:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>rm -f scala3-${SCALA_VERSION}-x86_64-pc-linux.tar.gz<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Install sbt (Scala Build Tool)<\/h2>\n\n\n\n<p>sbt is the standard build tool for Scala projects. It handles dependency management, compilation, testing, and packaging. If you used Coursier in Step 2, sbt is already installed. Otherwise, install it manually.<\/p>\n\n\n\n<p><strong>On RHEL 10 \/ Rocky Linux 10 \/ AlmaLinux 10:<\/strong><\/p>\n\n\n\n<p>Add the sbt repository and install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rm -f \/etc\/yum.repos.d\/bintray-rpm.repo\ncurl -L https:\/\/www.scala-sbt.org\/sbt-rpm.repo | sudo tee \/etc\/yum.repos.d\/sbt-rpm.repo\nsudo dnf install -y sbt<\/code><\/pre>\n\n\n\n<p><strong>On Ubuntu 24.04:<\/strong><\/p>\n\n\n\n<p>Add the sbt APT repository and install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb https:\/\/repo.scala-sbt.org\/scalasbt\/debian all main\" | sudo tee \/etc\/apt\/sources.list.d\/sbt.list\ncurl -sL \"https:\/\/keyserver.ubuntu.com\/pks\/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823\" | sudo gpg --dearmor -o \/etc\/apt\/trusted.gpg.d\/sbt.gpg\nsudo apt update\nsudo apt install -y sbt<\/code><\/pre>\n\n\n\n<p>Confirm sbt is installed by checking its version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sbt --version<\/code><\/pre>\n\n\n\n<p>The first run downloads required components, then displays the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sbt version in this project: 1.12.6\nsbt script version: 1.12.6<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Verify Scala Installation<\/h2>\n\n\n\n<p>Run a quick check to confirm all components are working together. Verify that both <code>scala<\/code> and <code>scalac<\/code> (the compiler) are available:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scala -version\nscalac -version<\/code><\/pre>\n\n\n\n<p>Both commands should return version 3.8.2. Also verify Java is detected:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -version<\/code><\/pre>\n\n\n\n<p>If any of these fail, check that your PATH includes the Scala binary directory. For Coursier installations, ensure <code>~\/.local\/share\/coursier\/bin<\/code> is in your PATH.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Scala REPL Basics<\/h2>\n\n\n\n<p>The Scala REPL (Read-Eval-Print Loop) lets you run Scala code interactively &#8211; useful for testing snippets and learning the language. Start it by typing <code>scala<\/code> without arguments:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scala<\/code><\/pre>\n\n\n\n<p>You enter the interactive Scala shell:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Welcome to Scala 3.8.2 (21.0.6, Java OpenJDK 64-Bit Server VM).\nType in expressions for evaluation. Or try :help.\n\nscala><\/code><\/pre>\n\n\n\n<p>Try a few basic operations to confirm everything works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scala> val greeting = \"Hello from Scala\"\nval greeting: String = Hello from Scala\n\nscala> println(greeting)\nHello from Scala\n\nscala> val numbers = List(1, 2, 3, 4, 5)\nval numbers: List[Int] = List(1, 2, 3, 4, 5)\n\nscala> numbers.map(_ * 2)\nval res0: List[Int] = List(2, 4, 6, 8, 10)\n\nscala> :quit<\/code><\/pre>\n\n\n\n<p>The REPL supports tab completion, multi-line input, and all Scala 3 features including <a href=\"https:\/\/computingforgeeks.com\/install-kotlin-programming-language-on-linux-mint-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">functional programming<\/a> patterns like pattern matching and higher-order functions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Create Your First Scala Project with sbt<\/h2>\n\n\n\n<p>The fastest way to start a new Scala 3 project is using the <code>sbt new<\/code> command with the official Scala 3 template. Create a project directory and initialize it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sbt new scala\/scala3.g8<\/code><\/pre>\n\n\n\n<p>When prompted, enter a project name (for example, <code>hello-scala<\/code>). sbt creates the project structure:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hello-scala\/\n  \u251c\u2500\u2500 build.sbt\n  \u251c\u2500\u2500 project\/\n  \u2502   \u2514\u2500\u2500 build.properties\n  \u2514\u2500\u2500 src\/\n      \u251c\u2500\u2500 main\/\n      \u2502   \u2514\u2500\u2500 scala\/\n      \u2502       \u2514\u2500\u2500 Main.scala\n      \u2514\u2500\u2500 test\/\n          \u2514\u2500\u2500 scala\/\n              \u2514\u2500\u2500 MySuite.scala<\/code><\/pre>\n\n\n\n<p>The <code>build.sbt<\/code> file contains the project configuration including the Scala version and dependencies. The <code>src\/main\/scala\/Main.scala<\/code> file contains a sample application.<\/p>\n\n\n\n<p>Open the main source file to see the generated code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat hello-scala\/src\/main\/scala\/Main.scala<\/code><\/pre>\n\n\n\n<p>The default template generates a simple application:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@main def hello(): Unit =\n  println(\"Hello world!\")\n  println(msg)\n\ndef msg = \"I was compiled by Scala 3. :)\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8: Compile and Run Your Scala Application<\/h2>\n\n\n\n<p>Navigate into the project directory and use sbt to compile and run the application:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd hello-scala\nsbt run<\/code><\/pre>\n\n\n\n<p>sbt downloads dependencies on the first run, then compiles and executes the application. You should see the output from Main.scala:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[info] compiling 1 Scala source to \/home\/user\/hello-scala\/target\/scala-3.8.2\/classes ...\n[info] running hello\nHello world!\nI was compiled by Scala 3. :)\n[success] Total time: 5 s<\/code><\/pre>\n\n\n\n<p>Other useful sbt commands for development:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>sbt compile<\/code> &#8211; compile without running<\/li>\n\n<li><code>sbt test<\/code> &#8211; run unit tests<\/li>\n\n<li><code>sbt console<\/code> &#8211; open REPL with project dependencies loaded<\/li>\n\n<li><code>sbt package<\/code> &#8211; create a JAR file<\/li>\n\n<li><code>sbt ~run<\/code> &#8211; recompile and re-run on every file change<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Scala 2 vs Scala 3 &#8211; Key Differences<\/h2>\n\n\n\n<p>Scala 3 (codenamed Dotty) is a major redesign of the language. If you are migrating from Scala 2, here are the most significant changes:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Scala 2<\/th><th>Scala 3<\/th><\/tr><\/thead><tbody><tr><td>Syntax<\/td><td>Braces required for blocks<\/td><td>Optional braces (indentation-based syntax)<\/td><\/tr><tr><td>Implicits<\/td><td><code>implicit<\/code> keyword (complex)<\/td><td><code>given<\/code>\/<code>using<\/code> clauses (clearer intent)<\/td><\/tr><tr><td>Enums<\/td><td>Sealed trait + case objects pattern<\/td><td>Native <code>enum<\/code> keyword<\/td><\/tr><tr><td>Type system<\/td><td>Path-dependent types<\/td><td>Union types, intersection types, opaque types<\/td><\/tr><tr><td>Macros<\/td><td>Scala 2 macros (experimental)<\/td><td>Redesigned macro system (stable)<\/td><\/tr><tr><td>Entry point<\/td><td><code>def main(args: Array[String])<\/code><\/td><td><code>@main<\/code> annotation<\/td><\/tr><tr><td>Trait parameters<\/td><td>Not supported<\/td><td>Traits can have parameters<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Scala 3 maintains backward compatibility with most Scala 2 libraries through the TASTy interchange format. You can use Scala 2 dependencies in Scala 3 projects without issues in most cases. The <a href=\"https:\/\/computingforgeeks.com\/install-gradle-on-ubuntu-debian-from-ppa\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gradle build tool<\/a> also supports Scala projects as an alternative to sbt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>You now have Scala 3.8.2 and sbt installed on your Linux system, ready for development. The Coursier method is the easiest to maintain and update, while the manual tarball approach works better for shared servers where system-wide installation is needed.<\/p>\n\n\n\n<p>For production Scala applications, set up a proper CI\/CD pipeline with <a href=\"https:\/\/computingforgeeks.com\/how-to-install-jenkins-server-stable-on-centos-7\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jenkins<\/a> or GitHub Actions, configure proper JVM memory settings with <code>-Xmx<\/code> flags, and use sbt assembly or sbt-native-packager to build deployable artifacts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scala is a modern programming language that runs on the Java Virtual Machine (JVM). It combines object-oriented and functional programming in a statically typed language, making it a strong choice for building scalable backend services, data pipelines, and distributed systems. Scala powers frameworks like Apache Spark, Akka, and Play Framework. This guide covers installing Scala &#8230; <a title=\"Install Scala on RHEL 10 \/ Ubuntu 24.04\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/install-scala-rhel-ubuntu\/\" aria-label=\"Read more about Install Scala on RHEL 10 \/ Ubuntu 24.04\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":10215,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,50,68,73],"tags":[311,4633,4632],"class_list":["post-10144","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux-tutorials","category-programming","category-rhel","tag-java","tag-jvm","tag-scala"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/10144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=10144"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/10144\/revisions"}],"predecessor-version":[{"id":163678,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/10144\/revisions\/163678"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/10215"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=10144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=10144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=10144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}