JDK 8 Installation

On SonarQube 7.8 it is recommended to use Java 11, while yet supported Java 8. Since SonarQube 7.9, Java 11 is required.

1. Get Oracle JDK 8

1.1 Visit Oracle JDK download page

1.2 Find the latest JDK 8 version, in this example we will get jdk-8u111-windows-x64.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 8

1.1 Visit Oracle JDK download page

1.2 Find the latest JDK 8 version, in this example we will get jdk-8u181-linux-x64.tar.gz via wget command to /tmp folder

$ wget --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /tmp \ 
    http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz

2. Extracts to /opt/java

2.1 Extracts the downloaded file to /opt/java

$ sudo mkdir /opt/java

$ sudo tar -xvzf /tmp/jdk-8u181-linux-x64.tar.gz -C /opt/java
jdk1.8.0_181/
jdk1.8.0_181/THIRDPARTYLICENSEREADME-JAVAFX.txt
jdk1.8.0_181/THIRDPARTYLICENSEREADME.txt
jdk1.8.0_181/lib/
jdk1.8.0_181/lib/jexec
jdk1.8.0_181/lib/javafx-mx.jar
jdk1.8.0_181/lib/packager.jar
jdk1.8.0_181/lib/visualvm/

$ 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 Sep 23 01:27 jdk1.8.0_181

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/jdk1.8.0_181 /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
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b14, mixed mode)