Install Zulu JDK on Ubuntu

ZULU JDK on Ubuntu

Recently I moved my server to Ubuntu from windows. I went with Ubuntu 16.04 server edition as it is lightweight as compared to the desktop edition and comes preloaded with some server tools. As I am running OpenHAB for my home automation system I wanted to install it on the server but the server edition doesn’t come with JAVA/JDK pre-installed. As per OpenHAB, Zulu JDK is the recommended JAVA platform and performs better as compared to OpenJDK. Though Oracle JDK can be installed, I thought of trying ZULU. So let’s see how to install it.

Zulu comes with JDK for almost all OS and both in 32/64 bit edition. The installation method included using the repository or downloading the zip file. First I tried with apt-get (For Ubuntu) method by adding the repositories as provided on their site, but unfortunately, that didn’t work for me. So I moved ahead by downloading the zip file.

STEP 1 (Download):

Download the required JDK as per your system or OS from here. Or to directly download zulu8.30.0.1-jdk8.0.172-linux_i686.tar.gz click here.

STEP 2 (Extract and Copy):

After download complete, copy the downloaded file to the server by using any method like drive or SCP or anything else. Create a folder jvm inside /usr/lib folder. You can use any location that you are interested in.

$ mkdir /usr/lib/jvm

Copy the zip file to the newly created directory and extract it.

$ cp zulu8.30.0.1-jdk8.0.172-linux_i686.tar.gz /usr/lib/jvm/
$ cd /usr/lib/jvm/
$ sudo tar -xzvf zulu8.30.0.1-jdk8.0.172-linux_i686.tar.gz

The extracted files will be in a new folder and the will have a long name, so for convenience rename it to something shorter,

$ sudo mv zulu8.30.0.1-jdk8.0.172-linux_i686 zulu-8

That’s it, we don’t need any script to run for installation or build. Simply extraction organizes the files into respective folders and all are precompiled binaries. Now you can use JAVA by navigating to the folder /bin inside the installation directory.

STEP 3 (Setting up Environment Variables):

Though JAVA can be used by navigating to the installation folder, it’s not convenient any tools we will be installing, we will have to provide the path to the JSK folder manually. So to avoid that we need to setup couples of Environmental Variables like JAVA_HOME and PATH. While JAVA_HOME is used by tools installed on the system like IDE and all to find out the installed JAVA folder, PATH is used by the system to find the same. To set it up, use the following commands,

$ sudo nano /etc/environment

At the end of the PATHline add :/usr/lib/jvm/zulu-8/bin. Again don’t forget to change the path, if you have installed the JDK into some other directory and same foes with the JAVA_HOME variable. Add the JAVA_HOME="/usr/lib/jvm/zulu-8"line to the file and save it.

Now use

source /etc/environment

It loads the system variables. By typing in java -versioninto the terminal, you can check if everything went right. If you have multiple installations of JDK, you can change the default JDK to use, by using the command,

sudo update-alternatives --config java

Related posts

Leave a Comment