- How To Install Java on Windows 10 Step by Step
- Download Java for Windows 10
- Install Java on Windows 10
- Add JAVA_HOME
- Append JAVA_HOME to PATH
- Write First Java Program
- Conclusion
- How to Install Java on Windows
- Check if Java Is Installed
- Download Java for Windows 10
- Install Java on Windows 10
- Step 1: Run the Downloaded File
- Step 2: Configure the Installation Wizard
- Set Environmental Variables in Java
- Step 1: Add Java to System Variables
- Step 2: Add JAVA_HOME Variable
- Test the Java Installation
- Step 1: Write a Test Java Script
- Step 2: Compile the Test Java Script
How To Install Java on Windows 10 Step by Step
In this short tutorial, we’re going to take a close look at how to install Java on Windows 10.
We’ll first start with a little insight into how to download Java. Then, we’ll explain how to install it on Windows 10. Then, we’re going to see how to properly set JAVA_HOME environment variable.
Lastly, we’ll highlight different ways to check Java and JDK versions on Windows 10.
Download Java for Windows 10
In this section, we’re going to cover in-depth all the steps required to download Java for Windows 10.
As a matter of fact, downloading Java is a piece of cake. It’s just a matter of a few clicks and simple one-time steps.
First, we need to visit the official oracle download page and choose the right release for the Java SE Platform. At this point in time, the latest version is Java 18.
Secondarily, we need to click on the Windows tab.
Bear in mind that Oracle has dropped the support for 32 bit systems. As a result, we can use Java SE only in 64 bit machines.
Oracle offers three options to install Java on Windows. We can use a compressed archive file, a x64 Installer or a x64 MSI Installer.
For instance, let’s choose the x64 Installer option:
Before Java 17, we had to accept the Oracle Technology Network License Agreement to proceed to the next step, which is not the case for Java 18
Lastly, a simple click on the download link will do the job. Easy, right?
Install Java on Windows 10
Now that we downloaded Java for Windows 10, let’s see how to install it.
Basically, the process of installing Java on Windows 10 is pretty easy and simple.
In general, we don’t need to change anything during the installation, we can go with the default settings and follow the suggested instructions.
Firstly, we need to double click on the downloaded installer file to start the installation process:
Secondarily, we click Next to continue:
Note that, “C:\Program Files\Java\” is the default Java installation folder! However, we can always change it if we want that.
Then, we keep hitting Next until the installation is complete:
Finally, we close the installer wizard to complete the installation.
Set Java Path in Windows 10
Now that we have installed Java with success, it’s time to proceed to the next step.
In this short chapter, we’re going to dive deep into how to set JAVA_HOME environment variable on Windows 10.
Add JAVA_HOME
The basic idea behind setting the Java Path is to make all the Java commands like java and javac accessible from everywhere. That way, we can run Java programs from anywhere.
Please note that, JAVA_HOME should point to the JDK not the JRE.
First, let’s open the Advanced System Settings. To do that, we just need to press Windows key + Pause Key.
Alternatively, we can type View advanced system settings in the search box.
Once the System Properties window is opened, we click on Environment Variables:
Secondarily, we click on the New button to create a new environment variable with JAVA_HOME as name and the path to the JDK directory as value:
As we can see, the JAVA_HOME environment variable points to the JDK folder which C:\Program Files\Java\jdk-18.0.1.1 is in our case.
Append JAVA_HOME to PATH
Next, we need to update the PATH variable by adding a new entry for %JAVA_HOME\bin%:
Finally, we can click OK to save and apply the changes.
That’s all we can say about downloading and installing java on windows 10. Now, we’re ready to write our first Java program.
Check Java Version on Windows 10
There are multiple ways that we can use to check Java version on Windows 10. The most obvious and basic way is to use the terminal.
Firstly, press Win+R and type cmd to open the Command Prompt. After that, type java -version and press Enter:
C:\Users\Asus>java -version java 18.0.1.1 2022-04-22 Java(TM) SE Runtime Environment (build 18.0.1.1+2-6) Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing) C:\Users\Asus>
The output means that Java is properly installed on our operating system.
Alternatively, we can type “Java” in the search box and click on “About Java”:
Please bear in mind that multiple versions of JDK can be installed on the same on Windows 10 machine. So, it’s important to make sure the JAVA_HOME environment variable points to the right JDK release.
Let’s open a new command prompt and type:
C:\Users\Asus>echo %JAVA_HOME% C:\Program Files\Java\jdk-18.0.1.1 C:\Users\Asus>
As show above, the environment variable JAVA_HOME points to the directory of the lastest JDK version.
We can also use javac -version to verify the version of the installed JDK:
C:\Users\Asus>javac -version javac 18.0.1.1 C:\Users\Asus>
Another important thing to note here is that the JDK version can be different from the JRE version on the same machine.
Please keep in mind that we need always to check for new Java updates and install them to keep our machines up-to-date with the latest releases.
In case you want to check how to enable Java on Chrome and other browsers, feel free to take a look at this article: https://devwithus.com/enable-java-chrome/
Write First Java Program
Now that we installed Java, let’s see how to create our first Java program.
To do so, let’s open an IDE or a text editor of your choice, for example, Notepad++, and create a new file (ctrl+n).
Next, we need to append the following code in our newely created file:
class HelloTest < public static void main(String args[])< System.out.println("Hello Test"); > >
Now, let’s save our file anywhere we want under the name: HelloTest.java
In order to execute our Java program, we need to compile it first. So, let’s open a terminal and type:
C:\Users\Asus\Workspace\Java>javac HelloTest.java C:\Users\Asus\Workspace\Java>dir Directory of C:\Users\Asus\Workspace\Java 06/19/2022 02:26 PM 422 HelloTest.class 06/19/2022 02:25 PM 103 HelloTest.java 2 File(s) 525 bytes 2 Dir(s) 31,034,630,144 bytes free
As we can see, javac creates a new file with the name HelloTest.class. This means that the compilation phase is done with success.
Lastly, let’s run our Java program using the java command:
C:\Users\Asus\OneDrive\Bureau\Java>java HelloTest Hello Test C:\Users\Asus\OneDrive\Bureau\Java>
Please bear in mind that we don’t need to specify the extension when executing a Java file.
Conclusion
In this article, we’ve explained how to tackle the challenge of downloading and installing Java on Windows 10. Then, we’ve seen how to add JAVA_HOME and append %JAVA_HOME\bin% to the Path.
Lastly, we have showcased how to verify and check the installed Java version.
Thanks for reading. Have a nice day!
Liked the Article? Share it on Social media!
How to Install Java on Windows
The Java Development Kit (JDK) is software used for Java programming, 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 executable by the JVM and JRE.
In this tutorial, you will learn to install the Java Development Kit on Windows.
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:
The command outputs the Java version on your system. If Java isn’t installed, the output is a message stating that Java isn’t recognized as an internal or external command.
Note: If you need to set up Java on a different system, check out our tutorials for installing Java on Ubuntu, Fedora, Raspberry Pi, CentOS 8, and CentOS 7.
Download Java for Windows 10
Download the latest Java Development Kit installation file for Windows 10 to have the latest features and bug 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, proceed with installing Java on your Windows system.
Step 1: Run the Downloaded File
Double-click the downloaded file to start the installation.
Step 2: Configure the Installation Wizard
After running the installation file, the installation wizard welcome screen appears.
1. Click Next to proceed to the next step.
2. Choose the destination folder for the Java installation files or stick to the default path. Click Next to proceed.
3. Wait for the wizard to finish the installation process until the Successfully Installed message appears. Click Close to exit the wizard.
Set Environmental Variables in Java
Set Java environment variables to enable program compiling from any directory. To do so, 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 result.
3. In the System Properties window, under the Advanced tab, click Environment Variables…
4. Under the System variables category, select the Path variable and click Edit:
5. Click the New button and enter the path to the Java bin directory:
Note: The default path is usually C:\Program Files\Java\jdk-17.0.1\bin.
6. Click OK to save the changes and exit the variable editing window.
Step 2: Add JAVA_HOME Variable
Some applications require the JAVA_HOME variable. Follow the steps below to create the variable:
1. In the Environment Variables window, under the System variables category, click the New… button to create a new variable.
2. Name the variable as JAVA_HOME.
3. In the variable value field, paste the path to your Java jdk directory and click 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 sure Java installed correctly:
If installed correctly, the command outputs the Java version. Make sure everything works by writing a simple program and compiling it. Follow the steps below:
Step 1: Write a Test Java Script
1. Open a text editor such as Notepad++ and create a new file.
2. Enter the following lines of code and click Save:
3. Name the file and save it as a Java source file (*.java).
Note: When using Notepad, select 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 location and use the following syntax to compile the program:
After a successful compilation, the program generates a .class file in the file directory.
2. Run the program with the following syntax:
The output shows that the program runs correctly, displaying the Hello world! message.
Note: Our Knowledge Base also has a guide on how to install Java on MacOS.
This tutorial showed how to install the Java Development Kit on a Windows system. If you are interested in learning more about Java, read our list of 13 best Java IDEs for writing, debugging, and testing Java code.
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Need to check your Java version? Use one of these three methods to find the Java version installed on your system (Ubuntu, CentOS, or Debian).
The Date object is useful for checking the date that visitors arrive at your website. This guide will walk you through using Javascript to get a date from a client. You will see how to write a script to retrieve the current date.
Node.js is a popular back-end JavaScript runtime used for creating web servers and scalable network apps. NPM is a package manager for JavaScript and the default package manager for Node.js.
A DBMS facilitates data manipulation and provides an additional security layer for your database. This article lists the 25 best database management systems.