Java is an object-oriented, class-based high-level programming language that helps to develop applications for multiple platforms. The JDK (Java Development Kit) is a platform, along with the JVM (Java Virtual Machine) and the JRE (Java Runtime Environment) used to develop the Java applications. The JDK incorporates different development tools such as compiler, debuggers, class libraries, etc. that allow programmers to create Java applications that will be further run by the JVM and JRE.
In this tutorial, we will demonstrate how to install Java JDK on Windows Server 2022.
Prerequisites
- Running Windows Server 2022 on your system.
- You should have administrative privileges to install JAVA JDK.
Installation of Java JDK on Windows Server 2022
You will need to check whether Java JDK is already installed on your Windows Server or not before installing the JDK. To do this, open the command prompt using the start menu and type the following command to check the Java installation:
> Java --version
If you will get the message “`Java` isn’t recognized as an internal or external command, operable program, or batch fileâ€, it means Java is not installed on your system.
Now, perform the following steps to install the latest Java JDK version on Windows Server 2022:
Step 1: Download the Java JDK installer for Windows
Download the latest version of Java JDK (Java Development Kit) for Windows from the official Oracle website. Open the Oracle Java download page in your web browser.
At the time of writing this article, the two latest Java versions: Java 17 and Java 18 that are available for installation. Download the Java 17 latest long-term support version. Select the ‘Windows’ category and click on ‘x64 installer’ to download Java JDK on your system.
Step 2: Install Java JDK on Windows Server 2022
Once the download is completed, the installation file will be saved in your system ‘Downloads’ folder.
Now, run the Java JDK installer on your system. Right-click on the downloaded Java installation file and select ‘Run as Administrator to start the Java installation on your server.
After running the installer, the following installation wizard displays on the desktop. This wizard will guide you on how you can proceed with the Java installation process. Click on ‘Next’ for further proceed with Java installation.
Choose the folder in which you want to install Java and keep all the installation files. If you want to install Java in another folder instead of the default destination, click on ‘Change’. Otherwise, click on ‘Next’ to proceed to the default location.
After that, the Java installation will start on your system. Wait for the wizard to complete the installation process.
Once the Java is installed, the successfully installed confirmation message will show on the wizard. Click on the ‘Close’ button to exit the installation wizard.
Set Java Environment Variables
To enable the Java program compilation from any directory, set Java environment variables. To do this, perform the following steps:
- Navigate into the Windows Start Menu and search for ‘environment variable’. Select the result ‘Edit the system environment variables’.
- The ‘System Properties’ dialog will display on your desktop. Click on the ‘Environment Variables’ button.
- In the ‘System variable’ section, locate and select the ‘Path’ variable and further click on ‘Edit’.
- Now, click on the ‘New’ or ‘Browse’ button to add the Java bin path to the list.
- Once the Java path ‘C:Program FilesJavajdk-17.0.2bin’ is added, save changes and click on ‘Ok’ and exit the ‘Edit environment variable’ dialog.
Add variable Java_Home
Once you configured the Java environment variables, add the Java_Home variable. So, do the following steps:
- In the ‘Environment Variables’ dialog, move to the ‘System variables’ section and create a new variable by clicking on the ‘New’ button.
- Enter the variable name as Java_Home and paste the Java JDK directory path in the variable value field.
- Click on ‘OK’ to save changes.
Verify the Java Installation
Once the installation and environment variable configuration is completed, verify the Java installation on your Windows Server 2022. Open the command prompt from the start menu and type the following command to check whether java is installed on your system or not:
> Java –version
If Java is properly installed on your system, the following output should receive on the terminal:
Conclusion
Congratulations! Java is successfully installed on Windows Server 2022. That is all about Java installation. You can run your Java program using the terminal to test the installation. Moreover, if you want to learn about java JDK, you can take help from the official Java JDK documentation. Thanks!
- Your search to the best windows hosting can end by clicking here.