Java Development Kit (JDK)

Java is currently the only permitted language for new Spotify backend services that serve end-user traffic.

How to install on Mac

Install the Java SE JDK with these commands:

brew tap homebrew/cask-versions
brew cask install java11

After installing the JDK, check its version number in your Terminal:

java -version

The proper response is:

java version "11.0.<build-number>" <release-date> <support-level>

Any version >= 11 is fine - a new major version of Java is released every six months now. NOTE: There are incompability issues with error-prone and Java 12 (, in case you encounter this, switch to Java 11.

How to install on Ubuntu (16.04 or 18.04)

Download the Linux X64 package of the Java SE Development Kit 11uXXX version from here (take the jdk-11.0.1_linux-x64_bin.tar.gz version):

You can download this package anywhere you want, we will move it to the right place. The default place to install java is: /usr/lib/jdk (you might see a /usr/lib/jvm folder if you already have the default openJDK version already installed.)

Create the directory and extract the downloaded tar.gz in it:

mkdir /usr/lib/jdk
tar -zxf ~/Downloads/jdk-11.0.1_linux-x64_bin.tar.gz -C /usr/lib/jdk

This will create a folder for you with the current JDK in it: /usr/lib/jdk/jdk-11.0.XXX/

Your java is ready but not "installed" yet. For that, you need to add its path to your environment (we will use the echo command to make sure the export worked properly).

export JAVA_HOME=/usr/lib/jdk/

Now we add it to our path and install a dependency:

export PATH=$PATH:$JAVA_HOME/bin
apt-get install libc6-i386

You should now be able to run the java command as follows:

$ java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

Note that if you already have Java version installed, you can verify which one is working by using the command (in this case I only have one installed, and the wrong one):

$ update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java
Nothing to configure.

You can add the freshly installed Java version by adding its alternative as follows:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jdk/jdk-11.0.1/bin/java 1
update-alternatives --config java

There are 2 choices for the alternative java (providing /usr/bin/java):

Selection Path Priority Status
0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 auto mode
* 1 /usr/lib/jdk/jdk-11.0.1/bin/java 1 manual mode
2 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1101 manual mode

Simply select the version you want (here 1) and the update will be performed. Now the java version command from above should output the right information.

jenv (Optional)

Installing jenv is optional, but can be convenient if you plan to work on backend projects and data projects. Currently backend services use java 11, but scio pipeline projects still require java 8.

Jenv is a tool that can help quickly swap between java versions, or set a default java version per project directory. To install jenv, follow the instructions for installation here. After jenv is installed, you can add java 11 to your jenv versions:

jenv add $(/usr/libexec/java_home -v 11)

If you have java 8 installed, you can also add it to your list of jenv versions:

jenv add $(/usr/libexec/java_home -v 1.8)
You can now view all of your java versions with the jenv versions command:
jenv versions

Finally run the following to enable the maven plugin, and also allow jenv to set the JAVA_HOME variable:

jenv enable-plugin maven
jenv enable-plugin export

To set your global java version with jenv, you can use the jenv global command, like jenv global 11.0

If you then switch to a project directory that requires java 8, you can set the local java version for that directory with jenv local 1.8, or just use jenv shell 1.8 to set it once for the shell.