Install multiple Java versions locally. SDKman to the rescue.

With the new Java Release Cycle you may need to have Java 8 (previous LTS) and Java 11 (current LTS) installed simultaneously and switch back and forth between them.

If you’re using Linux or MacOs then you can use https://sdkman.io/ . It is a tool to maintain multiple SDK-s locally without conflicts. Besides Java you can use it for gradle, maven, groovy etc.

Step-by-step guide

Install sdkman

$ curl -s "https://get.sdkman.io" | bash

List versions of Java

$ sdk list java
================================================================================
Available Java Versions
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 12.0.1.j9    | adpt    |            | 12.0.1.j9-adpt
               |     | 12.0.1.hs    | adpt    |            | 12.0.1.hs-adpt
               |     | 11.0.4.j9    | adpt    |            | 11.0.4.j9-adpt
               |     | 11.0.4.hs    | adpt    |            | 11.0.4.hs-adpt
               |     | 8.0.222.j9   | adpt    |            | 8.0.222.j9-adpt
               |     | 8.0.222.hs   | adpt    |            | 8.0.222.hs-adpt
 Amazon        |     | 11.0.4       | amzn    |            | 11.0.4-amzn
               |     | 8.0.222      | amzn    |            | 8.0.222-amzn
               |     | 8.0.202      | amzn    |            | 8.0.202-amzn
 Azul Zulu     |     | 13.0.0       | zulu    |            | 13.0.0-zulu
               |     | 12.0.2       | zulu    |            | 12.0.2-zulu
               |     | 11.0.4       | zulu    |            | 11.0.4-zulu
               |     | 10.0.2       | zulu    |            | 10.0.2-zulu
               |     | 9.0.7        | zulu    |            | 9.0.7-zulu
               |     | 8.0.222      | zulu    |            | 8.0.222-zulu
               |     | 8.0.202      | zulu    |            | 8.0.202-zulu
               |     | 7.0.232      | zulu    |            | 7.0.232-zulu
               |     | 7.0.181      | zulu    |            | 7.0.181-zulu
 Azul ZuluFX   |     | 11.0.2       | zulufx  |            | 11.0.2-zulufx
               |     | 8.0.202      | zulufx  |            | 8.0.202-zulufx
 BellSoft      |     | 13.0.0       | librca  |            | 13.0.0-librca
               |     | 12.0.2       | librca  |            | 12.0.2-librca
               |     | 11.0.4       | librca  |            | 11.0.4-librca
               |     | 8.0.222      | librca  |            | 8.0.222-librca
 GraalVM       |     | 19.2.0       | grl     |            | 19.2.0-grl
               |     | 19.2.0.1     | grl     |            | 19.2.0.1-grl
               |     | 19.1.1       | grl     |            | 19.1.1-grl
               |     | 19.0.2       | grl     |            | 19.0.2-grl
               |     | 1.0.0        | grl     |            | 1.0.0-rc-16-grl
 Java.net      |     | 14.ea.15     | open    |            | 14.ea.15-open
               |     | 13.0.0       | open    |            | 13.0.0-open
               |     | 12.0.2       | open    |            | 12.0.2-open
               |     | 11.0.2       | open    |            | 11.0.2-open
               |     | 10.0.2       | open    |            | 10.0.2-open
               |     | 9.0.4        | open    |            | 9.0.4-open
 SAP           |     | 12.0.2       | sapmchn |            | 12.0.2-sapmchn
               |     | 11.0.4       | sapmchn |            | 11.0.4-sapmchn
================================================================================
Use the Identifier for installation:
 
    $ sdk install java 11.0.3.hs-adpt
================================================================================

Install Java (JDK) versions

For JDK there are now multiple vendors. So besides the version you need to specify a vendor as well. The final version looks like <java.version>-<vndr> 

The general rule now is to use AdoptOpenJDK  since it has as for now the best community support. There is also incoming GraalVM  with promises to make Java extremely fast. It has its own versioning system not related to normal Java-s

AdoptOpenJDK has builds with two virtual machines: HotSpot (classic) and j9 (modern faster). You might want to have both in case you have problems with one of them.

$ sdk install java 8.0.222.hs-adpt
$ sdk install java 8.0.222.j9-adpt
$ sdk install java 11.0.4-sapmchn

You will be asked if you want to set the installed versions as default Java. You can choose to do it or not to do it. I will show you how to change it.

Switch between versions

Switch java version temporarily only for this shell:

$ sdk use java 11.0.4-sapmchn
Using java version 11.0.4-sapmchn in this shell.
 
$ sdk current java
Using java version 11.0.4-sapmchn
 
$ java -version
openjdk version "11.0.4" 2019-07-17 LTS
OpenJDK Runtime Environment (build 11.0.4+11-LTS-sapmachine)
OpenJDK 64-Bit Server VM (build 11.0.4+11-LTS-sapmachine, mixed mode

Switch java version globally for this and all future shells:

$ sdk default java 11.0.4.hs-adpt
Default java version set to 11.0.4.hs-adpt
 
$ sdk current java
Using java version 11.0.4.hs-adpt
 
$ java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)

Where are the installed files?

Check the directory ~/.sdkman/candidates

You can use it in the IntelliJ SDKs configuration

Is there an auto-update?

No, but you can do it manually.

$ sdk upgrade java 11.0.4-sapmchn
 
java is up-to-date

What about other SDKs like groovy, scala, kotlin etc?

You can list all SDKs supported by sdkman:

$ sdk list

For other SDKs the process is the same except you normally have one vendor and only need to tell which version you want.