Java and the JDK is one of the prerequisites for installing the Mule Runtime on a standalone server. In this post, we will see how to install the JDK on a Windows Server 2022.
Prerequisites
To follow this tutorial, we need to have a VM with Windows Server 2022. Once you've got that, follow the next steps:
Check if Java is in the system
First, open the command prompt and check if the JDK is already installed on the system by running the commandjava --version
If you get the ‘java’ is not recognized error then the JDK has not been installed and we can proceed to install it.
Download the JDK installer for Windows Server
Go to Oracle’s official web site and download the required version of the JDK for Windows Server. In this tutorial, we’ll be downloading JDK version 17 for Windows Server 2022.Once the download is complete, go to the download folder and run the installer as Administrator.
That will start the installation wizard. Click Next
Choose the installation folder for the JDK
Wait for the installer to be completed
Once Java is installed you’ll see the success message. Click on Close
Set the Java Environment Variables
In order for Java to work properly we need two environment variables: We need to add the JDK installation folder to the PATH env variable and create a new JAVA_HOME variable.For that, go to the Windows Start Menu and search for environment variable. From the results click on the Edit the system environment variables
Next, on the System Properties window, click on Environment Variables...
In the Environment Variables window, we need to first select the Path variable from the System variables section (at the bottom) and then click on Edit
Now, click on Browse and navigate to the Java bin path and click ok to add it to the list. Click OK
Next, let’s add a new environment variable for JAVA_HOME. From the Environment Variables window click on New in the System variables section
In the following window, type JAVA_HOME as variable name and in variable value provide the Java JDK directory of our recent installation. You can also find it by using the Browse Directory button. The directory should be the same as the previous one without the /bin. Click OK
Lastly, click OK to save our changes