JDK 11 Installation

Since SonarQube 7.8, Java 11 is the recommended jvm, and mandatory since SonarQube 7.9. If you are installing a previous version, you should install the JDK 8.

1. Get Oracle JDK 11

1.1 Visit Oracle JDK download page

1.2 Find the latest JDK 11 version, in this example we will get jdk-11.0.4_windows-x64_bin.exe, to your Downloads folder

2. Install the JDK

2.1 Install the downloaded file, following the wizard steps

3. Define system variables

3.1 Open system properties dialog

3.2 Select Advanced System Settings

3.3 Click on Environment Variables... button

3.4 On the Envirnoment Variable dialog, click on system variables New... button

3.5 Define the JAVA_HOME variable

3.6 Accept changes and close all dialogs

4. Quick check

4.1 A quick Java version check

> 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)

1. Get Oracle JDK 11

1.1 Visit OpenJDK download page

1.2 Find the latest JDK 11 version, in this example we will get openjdk-11.0.2_linux-x64_bin.tar.gz, and download it to /tmp folder

$ wget -P /tmp https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz

2. Extracts to /opt/java

2.1 Extracts the downloaded file to /opt/java

$ sudo mkdir /opt/java

$ sudo tar -xvzf /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz -C /opt/java
jdk-11/bin/jaotc
jdk-11/bin/jar
jdk-11/bin/jarsigner
jdk-11/bin/java
jdk-11/bin/javac
jdk-11/bin/javadoc
jdk-11/bin/javap
jdk-11/bin/jcmd
...

$ ls -la /opt/java
total 12
drwxr-xr-x 3 noroot noroot 4096 Dec 29 15:14 .
drwxr-xr-x 6 root   root   4096 Dec 29 15:14 ..
drwxr-xr-x 8 noroot noroot 4096 Aug  9 16:53 jdk-11

3. Define a symbolic link to Java

3.1 For easy upgrades on future it is highly recommended to create the symbolic link

$ sudo ln -s /opt/java/jdk-11 /opt/java/default-jdk

4. Include in PATH

4.1 Include the JDK in the PATH for all users

/etc/profile
JAVA_HOME=/opt/java/default-jdk
export JAVA_HOME

if [ "`id -u`" -eq 0 ]; then
  PATH="$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="$JAVA_HOME/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
. . .

After you change the /etc/profile file you need to logout and login again.

5. Quick check

5.1 A quick Java version check:

$ /opt/java/default-jdk/bin/java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)