Published 2013-12-01.
Last modified 2024-08-24.
Time to read: 4 minutes.
Windows users should have already worked through Installing Windows Subsystem for Linux.
Install a Terminal Emulator

Because a lot of your work with Scala tools is via the command line, you should install a terminal emulator
and get used to working with the keyboard, if you are not in that mode already.
The bash shell
is used for many code examples in this course.
If you have zsh
, then you can probably figure out any small changes if required to make the sample code work.
- On the rare occasions that I use macOS, I use iTerm2. Read about nine popular terminal emulators for macOS.
- Linux users have a variety of terminal applications to work with.
- Windows and WSL users should install the free Windows Terminal. If you install from the Microsoft Store (by clicking on the View in Store button), it will be automatically updated.
So Many Java; Much Confusion
TL;DR – Look for Temurin.
This topic became urgent when Oracle changed their licensing in such a way that most Java installers broke. This is to discourage most people from using Oracle Java. Temurin / Adoptium brand is a solid alternative.
The version of the JDK required to power Scala depends on the version of Scala you intend to use. For Scala 2.13, use Termurin 8 or 11, available for all operating systems here. The material in this course has been tested with many different Java brands for many different versions from 8 through 21. All have worked fine. Most Scala projects will work in production just fine on any currently maintained flavor.
As of 2024-08-16, Java 17 was used by the Scala developers, so if you have a choice, that might be the safest bet.
Java 11 support requires sbt 1.3+. Temurin 11 from Eclipse Adoptium, formerly known asOpenJDK, is the most tested version for Scala 2.13.
All integration tests on Travis CI are onOpenJDK’s JDK 11.
The main reason to switch from Java 8 to 11 is better support of Docker and Kubernetes;
Java 11 has better support for running in containers because of resources management (memory and CPU limits).
JDK 11 bases its memory settings on the Docker image limits and not the the global limits and won’t throw OOMException
so frequently.
There are also better GCs in Java 11+, for example
ZGC.
Microsoft wrote a nice summary of the differences between JDK 8 and JDK 11.
Here is a table I’ve taken from
docs.scala-lang.org
:

In summary, JDK 8 works with Scala 2.11.0+, and JDK 21 works with 2.13.11+.
For Further Reading
Free JDKs
The following list are all based on Oracle OpenJDK. Azul summarized the differences here.
- OpenJDK uses infrastructure, build and test scripts to produce prebuilt binaries from OpenJDK class libraries and a choice of either the OpenJDK HotSpot or AllOpenJDK binaries and scripts are open source licensed and available for free.
- Amazon Corretto (JDK 8 & 11) – Installation instructions
- Azul Zulu (JDK 8 & 11) – installation instructions
- Red Hat - See RedHat Becomes Steward of Java 8 and 11. Available here.
Install OpenJDK
As we’ve discussed, JDK version 8 or 11 is officially recommended for Scala 2.13. I have had no problems with JDK 17. Check the JDK version installed on your computer by typing this into a shell prompt:
$ java -version openjdk version "17.0.11" 2024-04-16 OpenJDK Runtime Environment (build 17.0.11+9-Ubuntu-1) OpenJDK 64-Bit Server VM (build 17.0.11+9-Ubuntu-1, mixed mode, sharing)
Now we’ll see how to install JDKs on Mac, Linux and Windows.
Mac
If you do not have Brew installed, install it by typing:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
Now you can use brew to install OpenJDK. To install the most recent JDK version, type:
$ brew untap AdoptOpenJDK/openjdk
$ brew install --cask temurin
Installing another JDK version:
$ brew tap homebrew/cask-versions
$ brew install --cask temurin8
You could also install other versions of OpenJDK:
$ brew install --cask temurin9
$ brew install --cask temurin11
$ brew install --cask temurin17
You can list the JDKs available on your Mac. Here is my collection of JDKs:
$ jenv versions system * 1.8 (set by /Users/mslinn/.jenv/version) 1.8.0.111 12.0 12.0.1 openjdk64-12.0.1 oracle64-1.8.0.111
If you have a JDK that jenv
does not know about,
you can manually add specific JDKs to jenv
:
$ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
You can use jenv
to set any JDK to be active:
$ jenv global 1.8
$ java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
Debian, Ubuntu and Windows Subsystem for Linux
This is an interesting option for installing Java on Ubuntu / WSL.
$ yes | sudo apt install --no-install-recommends default-jdk
This information about Debian and Ubuntu is also applicable to WSL because its
default guest Linux image is Ubuntu.
You could use Oracle’s
Linux instructions
to install their JDK, but I recommend that you wean yourself away from Oracle’s JDK now.
It is better to use apt
for system maintenance.
The Debian Wiki has a really good article
on apt
.
$ sudo apt install openjdk-8-jdk
Check to see how many versions of Java exist on your system.
For the various Linux distributions, the directories that Java is installed into vary widely,
however Ubuntu and other Debian offshoots often uses subdirectories of
/usr/lib/jvm
, for example /usr/lib/jvm/java-8-oracle
.
$ sudo update-alternatives --config java There is 1 choice for the alternative java (providing /usr/bin/java).
Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode * 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Now confirm that the proper version of Java is set as the default:
$ java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
Native Windows
This is not a good idea. Native Windows is a horrible development environment for Scala. Really, really bad. Don’t do this!
Instead, install Windows Subsystem for Linux (WSL) and follow the instructions above for Ubuntu.
If you enjoy suffering for no reason, you can install OpenJDK for Windows x64 for Windows x64 from here.
© Copyright 1994-2024 Michael Slinn. All rights reserved.
If you would like to request to use this copyright-protected work in any manner,
please send an email.
This website was made using Jekyll and Mike Slinn’s Jekyll Plugins.