< FrankJS />

Installing Oracle JDK on Ubuntu / Debian

  1. Go to Oracle’s Java website, and download the JDK for your system. The file I personally would download is jdk-xxxx-linux-x64.tar.gz because I want the 64-bit version, but you may need the equivalent of jdk-xxxx-linux-i586.tar.gz if you require the 32-bit version.

  2. I chose to place the JDK in my /opt/ path, so I entered the following commands in my terminal:

    1. cd /opt/

    2. sudo tar xfvz ~/Downloads/jdk-8u92-linux-x64.tar.gz

    3. Now that we have extracted the JDK into /opt/jdk1.8.0_92/ from the jdk-xxxx-linux-x64.tar.gz archive (again, your version may vary) we are ready to tell the system to use the new JDK as the default JDK.

    4. sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0_92/bin/java 3000

    5. sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_92/bin/javac 3000

  3. You can check the result of your actions now with the following commands:

    1. update-alternatives --display java (which shows you the currently selected java on your system as the default)

    2. java -version (which runs the currently default java on your system, displaying it’s version)

    3. update-alternatives --display javac (which shows you the currently selected javac on your system as the default)

    4. javac -version (which runs the currently default javac on your system, displaying it’s version)


Notes:

  1. I wanted to download the latest version, that was in tar.gz format and not rpm format since rpm is for systems such as Red Hat/CentOS/Fedora.

  2. We are using the tar command with the switches xvfz which uncompresses and extracts the gzipped tarball with verbosity.

  3. Here we are adding this specific instance of java and javac on our machines to the list of selectable java and javac versions on our machine. The priority of 3000 should, at least in my case, put this particular version above all other versions on your system, making it the new default.

Frank J Santaguida, 2022