Mike Slinn

Installing Scala Only

— Draft —

Published 2013-12-01. Last modified 2024-07-20.
Time to read: 1 minutes.

How to install the Scala command-line compiler.

Installing Scala without using Coursier is straightforward. Follow these directions to install the current version of Scala.

Mac

Shell
$ brew install scala
$ scala Welcome to Scala 2.13.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111). Type in expressions for evaluation. Or try :help.
scala>
2+2 res0: Int = 4
scala>
^D
$

Whenever a new version of Scala is released, brew tends to take a few extra days before it makes the new version available.

Linux and Windows Subsystem for Linux

Ubuntu

Apt is normally the best way of installing software on Ubuntu. However, I recommend that you not install Scala this way.

Sadly, Scala support for Debian distributions of Linux, such as Ubuntu, has always been weak at best. The version of Scala available for Debian and Ubuntu is many years out of date (v2.11.12, released November 09, 2017).

Shell
$ yes | sudo apt install scala
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libhawtjni-runtime-java libjansi-native-java libjansi1-java libjline2-java scala-library scala-parser-combinators
  scala-xml
Suggested packages:
  scala-doc
The following NEW packages will be installed:
  libhawtjni-runtime-java libjansi-native-java libjansi1-java libjline2-java scala scala-library
  scala-parser-combinators scala-xml
0 upgraded, 8 newly installed, 0 to remove and 10 not upgraded.
Need to get 25.1 MB of archives.
After this operation, 28.6 MB of additional disk space will be used.
Get:1 https://archive.ubuntu.com/ubuntu noble/universe amd64 libhawtjni-runtime-java all 1.18-1 [28.9 kB]
Get:2 https://archive.ubuntu.com/ubuntu noble/universe amd64 libjansi-native-java all 1.8-2 [24.1 kB]
Get:3 https://archive.ubuntu.com/ubuntu noble/universe amd64 libjansi1-java all 1.18-3ubuntu1 [56.0 kB]
Get:4 https://archive.ubuntu.com/ubuntu noble/universe amd64 libjline2-java all 2.14.6-5 [150 kB]
Get:5 https://archive.ubuntu.com/ubuntu noble/universe amd64 scala-library all 2.11.12-5 [9586 kB]
Get:6 https://archive.ubuntu.com/ubuntu noble/universe amd64 scala-parser-combinators all 1.0.3-3.1 [365 kB]
Get:7 https://archive.ubuntu.com/ubuntu noble/universe amd64 scala-xml all 1.0.3-3.1 [615 kB]
Get:8 https://archive.ubuntu.com/ubuntu noble/universe amd64 scala all 2.11.12-5 [14.2 MB]
Fetched 25.1 MB in 2s (13.4 MB/s)
Selecting previously unselected package libhawtjni-runtime-java.
(Reading database ... 141538 files and directories currently installed.)
Preparing to unpack .../0-libhawtjni-runtime-java_1.18-1_all.deb ...
Unpacking libhawtjni-runtime-java (1.18-1) ...
Selecting previously unselected package libjansi-native-java.
Preparing to unpack .../1-libjansi-native-java_1.8-2_all.deb ...
Unpacking libjansi-native-java (1.8-2) ...
Selecting previously unselected package libjansi1-java.
Preparing to unpack .../2-libjansi1-java_1.18-3ubuntu1_all.deb ...
Unpacking libjansi1-java (1.18-3ubuntu1) ...
Selecting previously unselected package libjline2-java.
Preparing to unpack .../3-libjline2-java_2.14.6-5_all.deb ...
Unpacking libjline2-java (2.14.6-5) ...
Selecting previously unselected package scala-library.
Preparing to unpack .../4-scala-library_2.11.12-5_all.deb ...
Unpacking scala-library (2.11.12-5) ...
Selecting previously unselected package scala-parser-combinators.
Preparing to unpack .../5-scala-parser-combinators_1.0.3-3.1_all.deb ...
Unpacking scala-parser-combinators (1.0.3-3.1) ...
Selecting previously unselected package scala-xml.
Preparing to unpack .../6-scala-xml_1.0.3-3.1_all.deb ...
Unpacking scala-xml (1.0.3-3.1) ...
Selecting previously unselected package scala.
Preparing to unpack .../7-scala_2.11.12-5_all.deb ...
Unpacking scala (2.11.12-5) ...
Setting up scala-library (2.11.12-5) ...
Setting up scala-xml (1.0.3-3.1) ...
Setting up scala-parser-combinators (1.0.3-3.1) ...
Setting up libhawtjni-runtime-java (1.18-1) ...
Setting up libjansi-native-java (1.8-2) ...
Setting up libjansi1-java (1.18-3ubuntu1) ...
Setting up libjline2-java (2.14.6-5) ...
Setting up scala (2.11.12-5) ...
update-alternatives: using /usr/share/scala-2.11/bin/scala to provide /usr/bin/scala (scala) in auto mode 

Installers

Various installers are provided at scala-lang.org/files/archive. If you have a Debian-derived distribution like Ubuntu, you could just download a .deb file, save it, and double-click on it to launch the Ubuntu Software Center. Scala will then be installed or upgraded. RPMs, tgzs and other formats are also provided. When this lecture was last updated, the most recent file was scala-2.13.14.deb.

You can install the Scala .deb file using a command line like this:

Shell
$ cd ~/Downloads
$ wget https://scala-lang.org/files/archive/scala-2.13.14.deb --2024-07-12 19:35:12-- https://scala-lang.org/files/archive/scala-2.13.14.deb Resolving scala-lang.org (scala-lang.org)... 172.64.80.1, 2606:4700:130:436c:6f75:6466:6c61:7265 Connecting to scala-lang.org (scala-lang.org)|172.64.80.1|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://www.scala-lang.org/files/archive/scala-2.13.14.deb [following] --2024-07-12 19:35:13-- https://www.scala-lang.org/files/archive/scala-2.13.14.deb Resolving www.scala-lang.org (www.scala-lang.org)... 172.64.80.1, 2606:4700:130:436c:6f75:6466:6c61:7265 Connecting to www.scala-lang.org (www.scala-lang.org)|172.64.80.1|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 695691736 (663M) [application/vnd.debian.binary-package] Saving to: `scala-2.13.14.deb’
scala-2.13.14.deb 100%[=================================================>] 663.46M 12.9MB/s in 45s
2024-07-12 19:35:55 (14.8 MB/s) - `scala-2.13.14.deb’ saved [695691736/695691736]

$ sudo dpkg -i scala-2.13.14.deb Selecting previously unselected package scala. (Reading database ... 141538 files and directories currently installed.) Preparing to unpack scala-2.13.14.deb ... Unpacking scala (2.13.14-400) ... Setting up scala (2.13.14-400) ... Creating system group: scala Creating system user: scala in scala with scala daemon-user and shell /bin/false Processing triggers for man-db (2.12.0-4build2) ...

View the version of Scala that is installed on your computer like this:

Shell
$ scala -version
Scala code runner version 2.13.14 -- Copyright 2002-2024, LAMP/EPFL and Lightbend, Inc. 
$ scalac -version Scala compiler version 2.13.14 -- Copyright 2002-2024, LAMP/EPFL and Lightbend, Inc.

Native Windows

This is a bad idea, remember? If you feel you must persist in this madness, navigate to All Available Versions page of scala-lang.org.

Click on the GitHub link for the release of interest:

Scroll to the bottom of the GitHub page, then click on the .zip file to download it.

Extract and run the installer in the bin/ directory.


* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.