Manually Install Oracle Java JDK 12 on Ubuntu 18.04 / 16.04

Oracle Java 12 has been released! This brief tutorial shows students and new users how to easily install it on Ubuntu 18.04 / 18.04 desktops… Since this is a new release, most apps that depend on Java may not yet support it… However, if  you’re brave and want to test it, then follow the steps below:

For developers who build apps based on Java, Java JDK and other tools are required during your build process…You can either use Oracle Java or OpenJDK, an open source alternative…

Oracle Java JDK is a development environment for developing applications and tools based on Java… It can also be used for testing applications and program developed using the Java programming language.

There is an open source version of Java JDK ( OpenJDK ) that can be installed easily using the apt-get command…. However, this post is going show you how to download and install Oracle Java from its original repository instead of the open source version…

To get Java JDK installed, follow the steps below:

Step 1: Download Java JDK

Download the latest Java SE Development Kit 12 LTS release from it from the link below….

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Take notes of the version number you’re downloading… If there’s a newer version number then the one below, select it instead…

You can also easily install Java DEB package by running the commands below…

cd /tmp
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12+33/312335d836a34c7c8bba9d963e26dc23/jdk-12_linux-x64_bin.deb

Step 2: Install Oracle Java

Now that you’ve downloaded the correct archive package for your system, run the commands below to install Oracle Java…

sudo dpkg -i jdk-12_linux-x64_bin.deb

After that, run the commands below to configure Java 12 as the default on Ubuntu… The commands below configure Ubuntu to use Java alternatives….

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-12/bin/java 2
sudo update-alternatives --config java

If you have other versions of Java installed and you ran the commands above, you should see a prompt to select the version of Java you want to make the default… If you don’t have another versions of Java installed, then the commands will return nothing…

Next, run the commands below to make Java 12 to be the default Java compiler for your Ubuntu desktop…

sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-12/bin/jar 2
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-12/bin/javac 2
sudo update-alternatives --set jar /usr/lib/jvm/jdk-12/bin/jar
sudo update-alternatives --set javac /usr/lib/jvm/jdk-12/bin/javac

That should get Java installed and configured…..

Run the commands below see if Ubuntu recognizes Java..

java -version

You should see the output below:

java version "12" 2019-03-19
Java(TM) SE Runtime Environment (build 12+33)
Java HotSpot(TM) 64-Bit Server VM (build 12+33, mixed mode, sharing)

Step 3: Create Java Environment Variables

To set JAVA environment variables, create a new file in the /etc/profile.d directory for Java JDK…

sudo nano /etc/profile.d/jdk12.sh

Then copy and paste the lines into the end of the file and save…

export J2SDKDIR=/usr/lib/jvm/java-12
export J2REDIR=/usr/lib/jvm/java-12
export PATH=$PATH:/usr/lib/jvm/java-12/bin:/usr/lib/jvm/java-12/db/bin
export JAVA_HOME=/usr/lib/jvm/java-12
export DERBY_HOME=/usr/lib/jvm/java-12/db

Next, run the commands below

source /etc/profile.d/jdk12.sh

The commands above should configure Java to work and function with Ubuntu. To test if Java is installed correctly, run the commands below.

You should see Java as been installed.

java -version

java version "12" 2019-03-19
Java(TM) SE Runtime Environment (build 12+33)
Java HotSpot(TM) 64-Bit Server VM (build 12+33, mixed mode, sharing)

Congratulations! You’ve just successfully install Java JDK 12 on Ubuntu 16.04 / 18.04

Summary:

This brief tutorial shows students and new users how to easily install Java JDK 12 on Ubuntu 16.04 / 18.04  desktops…. There are alternate methods that are available across the Internet that show users how to install Java from third-party PPAs or the OpenJDK versions.

This method installs the original versions from Oracle.

Enjoy!

You may also like the post below:

Migrate WordPress Website to New a Domain URL with MySQL / MariaDB

2 Replies to “Manually Install Oracle Java JDK 12 on Ubuntu 18.04 / 16.04

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: