Java 10 – Install JDK on Ubuntu

The first thing you will need to do when you want to write code in Java is install the Java SDK (Software Development Kit) on your workstation. On the windows side of things it is fairly straight forward to get it installed and start writing some code but if you are like me you primarily use Linux unless your at work, it is not obvious on how to install the Java SDK without the help of a 3rd party repository. In this post I will be showing you how you can install the Java SDK on a Ubuntu Linux computer without the need to use a 3rd party ppa.

Download the JDK Installer

There is more than one way to get the JDK, if you are on a workstation and have a web browser you can navigate to the following link http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html, accept the license agreement, and download the file corresponding to the version of Linux you are running. You may also find yourself in a situation where you do not have a web browser on the device you are working on or just want to download the file via command line, to do this you can use wget and issue the following command in the terminal and it will pass the proper cookie to accept the license and download the file to the current directory you are in.

In the case of a Debian based distro such as Ubuntu the link to the Java SDK is

http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8c52526dc134031e/jdk-10.0.1_linux-x64_bin.tar.gz

Once we have the tar.gz file on the system we can move to the next step

 

Unzip and Extract to the Install Directory

You will want to put some thought to where you want to install the Java SDK on your system, I chose to install it in /opt but you may put it anywhere you chose on your system as long as you have the proper rights to the directory you wish to install it to. Below is an example of installing it into the /opt directory.

At this point you should have a directory named “jdk-10.0.1” in /opt that contains all of the files that belong to the SDK. All of the instructions below will assume that you extracted the SDK into the /opt directory and have a directory “jdk-10.0.1” within /opt.

 

Set Environmental Variables

The last major step we have to do is add the install directory of the SDK to our system path and create a new environmental variable “JAVA_HOME”. To do that we will create a new file in /etc/profile.d and put those variables in there.

First create a new file in /etc/profile.d

Edith the file with Nano or vi

Add the following text into the file

Save and exit the file.

 

The last thing you will need to do is reboot your system and to validate that you did everything correctly issue the following command line and you should see output similar to below

At this point as long as everything went as I described you will have a working install of the Java SDK and can begin to develop Java applications. If you are interested on seeing a basic Hello World application to prove to yourself that your install works you can check out my post here.

I hope this post was able to help you, and if it did please share this article on social media.

Be the first to comment

Leave a Reply

Your email address will not be published.


*