Recently I moved my server to Ubuntu from windows. I went with Ubuntu 16.04 server edition as it is lightweight as compared to 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.
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.
Copy the zip file to the newly created directory and extract it.
cp zulu18.104.22.168-jdk8.0.172-linux_i686.tar.gz /usr/lib/jvm/ cd /usr/lib/jvm/ sudo tar -xzvf zulu22.214.171.124-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 zulu126.96.36.199-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.
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 PATH line 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 following line to the file and save it.
It loads the system variables. By typing in java -version into 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