The Java Development Kit ( JDK ) is software used for Java program, along with the Java Virtual Machine ( JVM ) and the Java Runtime Environment ( JRE ). The JDK includes the compiler and class libraries, allowing developers to create Java programs feasible by the JVM and JRE .
In this tutorial, you will learn to install the Java Development Kit on Windows.
Prerequisites
- A system running Windows 10.
- A network connection.
- Administrator privileges.
Note: Develop your core app services on PNAP ‘s Bare Metal Cloud servers to ensure superior performance. It ‘s cloud native and the perfect environment for the entire SDLC .
Check if Java Is Installed
Before installing the Java Development Kit, check if a Java version is already installed on Windows. Follow the steps below :
- Open a command prompt by typing cmd in the search bar and press Enter.
- Run the following command:
java -version
The instruction outputs the Java version on your system. If Java is n’t installed, the output is a message stating that Java is n’t recognized as an internal or external command .
Download Java for Windows 10
Download the latest Java Development Kit facility file for Windows 10 to have the latest features and hemipterous insect fixes .
- Using your preferred web browser, navigate to the Oracle Java Downloads page.
- On the Downloads page, click the x64 Installer download link under the Windows category. At the time of writing this article, Java version 17 is the latest long-term support Java version.
Wait for the download to complete .
Install Java on Windows 10
After downloading the installation file, continue with installing Java on your Windows system .
Follow the steps below :
Step 1: Run the Downloaded File
Double-click the downloaded file to start the initiation .
Step 2: Configure the Installation Wizard
After running the facility file, the installation wizard welcome screen appears .
1. Click Next to proceed to the following gradation .
2. Choose the finish booklet for the Java installation files or stand by to the nonpayment path. Click Next to proceed .
3. Wait for the ace to finish the facility procedure until the Successfully Installed message appears. Click Close to exit the sorcerer .
Set Environmental Variables in Java
Set Java environment variables to enable program compiling from any directory. To do therefore, follow the steps below :
Step 1: Add Java to System Variables
1. Open the Start menu and search for environment variables .
2. Select the Edit the system environment variables leave .
3. In the System Properties window, under the Advanced tab, suction stop Environment Variables…
4. Under the System variables class, select the Path variable and cluck Edit :
5. Click the New button and enter the path to the Java bin directory :
Read more: How To Do a Smokey Eye
Note: The default path is normally C : \Program Files\Java\jdk-17.0.1\bin .
6. Click OK to save the changes and passing the variable edit windowpane .
Step 2: Add JAVA_HOME Variable
Some applications require the JAVA_HOME variable. Follow the steps below to create the varying :
1. In the Environment Variables window, under the System variables category, click the New… button to create a fresh variable .
2. Name the variable as JAVA_HOME .
3. In the variable rate field, paste the path to your Java jdk directory and snap OK .
4. Confirm the changes by clicking OK in the Environment Variables and System properties windows .
Test the Java Installation
Run the java -version
command in the command prompt to make indisputable Java installed correctly :
If installed correctly, the command outputs the Java adaptation. Make sure everything works by writing a simple course of study and compiling it. Follow the steps below :
Step 1: Write a Test Java Script
1. Open a textbook editor such as Notepad++ and create a new charge .
2. Enter the pursue lines of code and click Save :
class HelloWorld{
public static void main(String args[]){
System.out.println("Hello world!");
}
}
3. Name the file and save it as a Java source file (*.java) .
Note: When using Notepad, choose All files for the Save as type option and add the .java extension to the file name .
Step 2: Compile the Test Java Script
1. In the command prompt, change the directory to the file ‘s localization and use the come syntax to compile the course of study :
javac [filename]
For exemplar :
After a successful compilation, the plan generates a .class file in the file directory .
2. Run the program with the following syntax :
java [filename]
The end product shows that the program runs correctly, displaying the Hello earth ! message .
conclusion
This tutorial showed how to install the Java Development Kit on a Windows system. If you are matter to in learning more about Java, read our list of 13 best Java IDEs for compose, debug, and testing Java code .