--- title: How to Install Java on Windows? - Scaler Topics description: This article by Scaler Topics covers a detail explanation of how to install Java in Windows. Read to know more. author: Aditi Patil category: Java --- :::section{.main} Before starting with writing code in java. It import to know how to install java in window 10. Java requires the Java Development Kit (JDK) for execution on Windows. The JDK, encompassing the Java Runtime Environment (JRE) and the Java Virtual Machine (JVM), is essential for running Java applications like Minecraft or developing complex projects. This guide outlines the steps to install JDK SE 16 on Windows 10, providing the necessary tools for Java development and execution. Prerequisites: * A system running Windows 10. * A network connection. * Administrator privileges. ::: :::section{.main} ## Check If Java Is Installed Having multiple Java versions on the same system can lead to conflicts, as applications might try to utilize different versions. Moreover, outdated versions can pose substantial security risks over time. Before proceeding to install java in windows, it's advisable to verify whether a Java version is already installed on Windows: * Type "cmd" in the Windows search bar. * Open the command prompt. * Execute the following command to check the Java version in Windows: java -version If the message says that Java is not recognized as an internal or external command, Java is not installed. If the system shows a Java version number, uninstall the previous Java installation before continuing. ::: :::section{.main} ## Which Java Distribution Do We Need? When selecting a Java Distribution, Oracle, Azul, Amazon, and Microsoft are among the companies that offer their Java installers based on the open-source OpenJDK project. Oracle is a reliable and widely used option. Oracle provides official Java installers and robust support for their JDK (Java Development Kit). This ensures a stable and well-maintained Java environment, making it a suitable choice for various development needs. :::section{.main} ## How To Install Java On Windows 10? To install Java in window, you should have to follow following steps: Step 1: Download Java for Windows Step 2: Run the Java Installer Step 3: Validate the JAVA_HOME setting Step 4: Confirm the Java PATH variable was set properly. Step 5: Run a JDK command to verify Java install was a success. **Step 1: Download Java for Windows** To download Java, you should have an account on oracle.com. You can sign in if you have one, or else you can sign up and create an account. Go to the site of `Java Oracle` using this [link](https://www.oracle.com/java/technologies/javase/jdk16-archive-downloads.html "{rel='nofollow'}") and download the latest version of `JDK 16` from `oracle.com` for windows. ![oracle window](https://scaler.com/topics/images/oracle-window.webp) ::: :::section{.tip} **NOTE:** Before downloading check whether your system is `32-bit or 64-bit` and download accordingly. In my case, it's `64-bit`. ::: :::section Clicking on the installation link will take you to a popup window as shown below. Click on I reviewed and accept the Oracle Technology Network License Agreement for `Oracle Java SE` development kit and click on the download button. It will take you to the login page of oracle.com, log in and start downloading the software. ![oracle login page](https://scaler.com/topics/images/oracle-login-page.webp) **Step 2: Run the Java Installer** Once the `JDK 16` download is complete, run the `.exe` file on windows to start install java in windows. First allow windows to make necessary changes during installation. ![allow changes](https://scaler.com/topics/images/allow-changes.webp) **Begin the installation by clicking on next.** ![begin the installation](https://scaler.com/topics/images/begin-the-installation.webp) **Step 3: Validate the JAVA_HOME setting** Select the PATH where you want to install Java in Windows. Leave it default and click on **Next**. ![default path](https://scaler.com/topics/images/default-path.webp) After installations are done, click on **Close**. ![done installation](https://scaler.com/topics/images/installation-done.webp) **Step 7: Confirm the Java PATH variable was set properly** After installing java in windows, we need to set environment variables PATH and CLASSPATH to run a program. `Path and Classpath` both are operating system level environment variables. `Path` is used to define where the system can find the `executables(.exe) files` and `classpath` is used to `specify the location of .class files. **PATH Variable:** * The `PATH variable` gives the location of executables like `javac and java` that are stored in the `bin folder` of Java. * When you try to execute a program from the command line, the operating system searches for the specified program in the current direction and executes if it's available. * In case the programs are not available in the current directory, the operating system verifies in the set of directories specified in the `‘PATH ’` environment variable. **CLASSPATH Variable:** * The `CLASSPATH` variable gives the location of library files that are stored in the `lib folder` of Java. * This environment variable is used to specify the location of the classes and packages. * When we try to import classes and packages that are not available in Java Standard Library. * JVM verifies the current direction for them, if not available it verifies the set of directories specified in the `CLASSPATH` environment variable. **To set these environment variables right-click on this PC and go to properties.** Click on Advanced System Settings. ![setting enviroment](https://scaler.com/topics/images/set-enviorment.webp) ![click advance](https://scaler.com/topics/images/click-advance.webp) Go to environment variables and click on **New**. Create a new PATH variable and set its path to the bin folder, which is in the installed JDK folder. ![enviroment variables](https://scaler.com/topics/images/go-to-enviroment-variables.webp) ![click new](https://scaler.com/topics/images/click-new.webp) ![create new path](https://scaler.com/topics/images/copy-address.webp) **Copy the address of the bin folder in JDK.** **Paste it in path variable value.** ![copy address for paste](https://scaler.com/topics/images/copy-address-for-paste.webp) ![paste in path](https://scaler.com/topics/images/paste-in-path.webp) Follow the same steps to create the CLASSPATH variable. Its variable value will be set to the lib folder in JDK. ![creating classpath](https://scaler.com/topics/images/creating-classpath.webp) The `PATH and CLASSPATH` variables are set. Click on **OK**. ![click ok](https://scaler.com/topics/images/click-ok.webp) **Here the installation of `JDK 16` is complete and environment variables are set.** **Step 5: Run a JDK command to verify Java install was a success.** After successfully installing java in windows all and setting all the changes, run the jdk command to verify java installed successfully or not. the easiest way to do this is to check the java version installed. ```java java -version ``` ::: :::section{.summary} ## Conclusion * Java needs JDK which is a superset of JRE and JVM to execute programs. * `javac` command is used to compile java code and ```java``` command is used to execute it. * `java` command activates JVM, which is responsible for executing java programs. * After successful installation, we need to set `environment` variables to execute java commands. :::