Alibaba requires no introduction. It is one of the popular and largest multinational conglomerate founded by Jack Ma, a business magnate and philanthropist from China. It is also world's fifth-largest internet company by revenue. It specializes in various sectors such as e-commerce, retail, Internet and technology. Alibaba team has provided significant contribution to open source projects. One such project is OpenJDK. The development team at Alibaba has developed many Java-based applications over the years. They have adopted OpenJDK and created their own JDK named "Alibaba Dragonwell8". It is the downstream version of OpenJDK and completely open source.
Alibaba Dragonwell is optimized for developing e-commerce, financial, logistics applications which are running on their 100k+ servers. It is certified as compatible with the Java SE standard. It is currently supports Linux/x86_64 platform only. Let us hope they will extend the support to Unix and other platforms soon. In this guide, we will see how to install Alibaba Dragonwell8 in Linux. I have tested this guide on Ubuntu 18.04 LTS server. However, it should work on other Linux distributions as well.
Install Alibaba Dragonwell8 in Linux
Download the latest Dragonwell JDK from the releases page.
$ wget https://github.com/alibaba/dragonwell8/releases/download/8.0-preview/Alibaba_Dragonwell8_Linux_x64_8.0-preview.tar.gz
Create a directory for the Java installation:
$ sudo mkdir /usr/local/dragonwell8
As of writing the guide, the latest version was 8, hence I created a directory named "dragonwell8". You can name it as you wish.
Next, extract the download tar archive to dragonwell8 directory using command:
$ sudo tar -zxf Alibaba_Dragonwell8_Linux_x64_8.0-preview.tar.gz -C /usr/local/dragonwell8/
Next, run the following commands to set Dragonwell as the default JVM in your Linux system:
$ sudo update-alternatives --install /usr/bin/java java /usr/local/dragonwell8/j2sdk-image/bin/java 100
$ sudo update-alternatives --install /usr/bin/javac javac /usr/local/dragonwell8/j2sdk-image/bin/javac 100
If you have multiple Java installations, run the following command to select your default java version by choosing a respective version number.
$ sudo update-alternatives --config java
Finally, check the current JDK version using command:
$ java -version openjdk version "1.8.0_202" OpenJDK Runtime Environment (Dragonwell 8.0-preview) (build 1.8.0_202-b30) OpenJDK 64-Bit Server VM (Dragonwell 8.0-preview) (build 25.202-b30, mixed mode)
Alternatively, you can check the Java version using the following commands as well.
$ update-alternatives --display java
java - auto mode link best version is /usr/local/dragonwell8/j2sdk-image/bin/java link currently points to /usr/local/dragonwell8/j2sdk-image/bin/java link java is /usr/bin/java /usr/local/dragonwell8/j2sdk-image/bin/java - priority 100
Set the JAVA_HOME Environment Variable
To enable Alibaba Dragonwell JDK for your application, simply set JAVA_HOME to point to the installation directory of Alibaba Dragonwell.
To do so, open /etc/environment file in any text editor:
$ sudo nano /etc/environment
Add the following line:
Make sure you replaced the path with your preferred Java version. Save and close the file. Update the changes using command:
$ source /etc/environment
Verify JAVA_HOME variable using command:
$ echo $JAVA_HOME
Sample output would be:
Congratulations! You have now successfully installed the Alibaba Dragonwell JDK on your system. Start developing your Java applications!
Update Alibaba Dragonwell
To update Alibaba Dragonwell in future, simply download the latest available version, extract it to the Java installation directory and make it as default Java with a higher priority number, for example 110.
$ sudo update-alternatives --install /usr/bin/java java /usr/local/<dragonwell_new_version>/bin/java 110
$ sudo update-alternatives --install /usr/bin/javac javac /usr/local/<dragonwell_new_version>/bin/javac 110
Finally, remove the older version if it is not required anymore as shown below.
$ sudo update-alternatives --remove java /usr/local/<dragonwell_old_version>/bin/java
$ sudo update-alternatives --remove javac /usr/local/<dragonwell_old_version>/bin/javac
$ sudo rm -rf /usr/local/<dragonwell_old_version>/
And, that's all for now. Hope this was useful. I will be soon here with another interesting topic. Stay tuned!