It might not be well known, but Oracle has changed the nature of Oracle JDK 8. It will not be possible to use JDK 8 for commercial purposes without incurring costs (as of February 2019). But, luckily when we look at the compatibility matrix we see that OpenJDK8 is now supported as well for a number of current products.
There is a migration initiated by WSO2 to newer versions of Oracle JDK e.g. 10 and more recently 11, but there is nothing final about the support by WSO2 products. The compatibility matrix only shows OpenJDK, Adopt OpenJDK 8 (for API Manager 2.6.0) and Oracle JDK 8.
So we need to switch to OpenJDK, at least if we are using it for commercial purposes. OpenJDK is available as an APT-GET or YUM install on Linux. But there is no real simple download for Windows machines (like we have with Oracle). One of my colleagues told me that there is a version available for Windows from AZUL Systems, called Zulu 8. According to the website, Zulu’s build of OpenJDK is free to use. This version is available as an MSI installer.
In order to try it out, I am going to install Zulu’s OpenJDK distribution in a Windows10 VirtualBox.
Setting Up VirtualBox
I will not describe in detail the setup of a VirtualBox 6 environment using Windows 10. However, the high-level steps are:
- Download and Install Virtualbox;
- Download the Windows 10 64 bit ISO from Microsoft;
- Create a new Virtual Machine (Windows 10) in Virtualbox;
- Do the Windows Setup when prompted (link to ISO file).
On top of the Windows environment I’ve installed Firefox as browser. Start your Virtual Machine, fire up your browser and go to the download page of Zulu 8.
Download the latest JDK 8 version of Zulu 8. This is an MSI (Windows Installer) product.
When the file is downloaded go to the Download location.
Click on the .msi file to start the installation.
Once the installation starts you’ll be requested to specify an installation folder. Keep to the default if you have no preference. This location is also important for the JAVA_HOME parameter as well as the Windows path in order to be able to access java and tools (like keytool) from anywhere. The path setting is done by the installer, the JAVA_HOME needs to be set manually.
When everything is installed go to environment variables and set a New System Variable.
Call it JAVA_HOME and set it to your location where Zulu 8 is installed.
During the installation procedure Java gets started up and wants network access, resulting possibly in an error message with regards to the Firewall. Accept the suggestions it gives or adhere to company policies when on a corporate machine.
With OpenJDK installed we can test it by typing java -version in a command window.
We can now download WSO2 products to test whether WSO2 products run with this OpenJDK distribution. I’ve chosen API Manager and downloaded the 2.6.0 version from WSO2. Since we run on Windows, we can unzip it on the desktop and simply start the wso2server.bat file from the bin folder.
After some time we get the message that the WSO2 API Manager has started and that the carbon console is available on https://localhost:9443/carbon.
We open the browser and navigate to the home page. the default credentials are, as with all WSO2 products, admin / admin. As we can see the systems is running on Windows 10 with the OpenJDK 8 runtime and the logs exhibited no errors to indicate anything was wrong.
I’ve tried to deploy the default api, which worked but have not tried it / tested it beyond that.
But what about installation on Linux? Well, that is actually quite easy. My training environments are on Centos7 and we have OpenJDK as a standard in that environment. When both Oracle JDK and OpenJDK are available then changing from Oracle to OpenJDK is a matter of typing
alternatives --config java and selecting the required version.
If OpenJDK is not yet installed then use your package manager to install it. On a CentOS distro, it is done using this command:
sudo yum install -y java-1.8.0-openjdk
The -y makes for an automated install. If your Linux version uses apt-get, you use that command to install it. Google for the right combination of commands, since you might need to update the system before being able to install OpenJDK.
Of course, JAVA_HOME needs to be set in all cases as well as the path extended with the link to the /bin directory of the OpenJDK installation.
For WSO2 products, as they’re java-based, it does not matter whether we use OpenJDK on Windows or Linux, it works the same on both operating systems.
Do you have any questions left after reading this blog? Feel free to reach out to me by leaving a comment below.