If you want to run any Java program on your Windows PC, you won't be able to do it without installing the Java Development Kit (JDK for short).

The JDK also contains the Java Runtime Environment (or JRE) which is the core of a Java program.

If you are a beginner trying to learn how to run Java programs in your Windows operating system, then you might face difficulties installing Java correctly on your computer. But fear not! I will cover everything you need to know to prepare your Windows computer fully for running Java programs.

I will be using Windows 11 in this article, but the same method is applicable for the other versions of the Windows operating system as well.

Download Java from Oracle

If you are wondering why we download Java from Oracle, then the following excerpt from Wikipedia will help:

Java is a set of computer software and specifications developed by James Gosling at Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment.

We download the official JDK directly from the official website of Oracle. So, go to their website: https://www.oracle.com/.

Screenshot--13--1

You might get this type of prompt to remind you to go to the country closer to you so that you can get a better downloading speed. As I am from Bangladesh, so it is suggesting that I visit Oracle Bangladesh.

Screenshot--14-

You can select the country closer to you to get a better download speed, but if you do not want that and just download from the global site instead, that's fine, too. You will get the exact installer file from there as well.

Then the website might reloaded itself.

Screenshot--17-

Click on Products.

Screenshot--18-

Then click Java.

Screenshot--19-

It will take us to the product page of Java.

Screenshot--21-

Click Download Java.

Screenshot--21--1

Then you will get the download page.

Screenshot--22-

Simply scroll down a little until you get the OS (Operating System) selection tab.

Screenshot--23-

Since you want to install Java on your Windows computer, simply click Windows.

Screenshot--24-

Then Click x64 Installer. You will get a prompt to download the installer file.

Screenshot--25-

Download the executable file. You'll need to wait a little while for it to complete the downloading process.

Screenshot--26-

How to Install Java

After downloading the file, you will get an executable file like below:

Screenshot--27-

Simply double-click on that file. An installation wizard will appear.

Screenshot--28-
Screenshot--29-

Click Next>.

Screenshot--30-

We will use the default directory. So click Next>.

Screenshot--31-

Finish the installation process.

Screenshot--32-
Screenshot--33-

After finishing the installation, click Close to close the installation wizard.

Screenshot--35-

How to Add the Directory to the Path of the Environment Variable

Open the file explorer.

Screenshot--36-

Go to the directory where you have installed the installer earlier. In this case, the default directory is always the C drive.

After going into the C drive, go into the Program Files folder.

Screenshot--38-

Go in to the Java folder.

Screenshot--39-

Go into the jdk-17.0.2 folder. Here, 17.0.2 represents the JDK version. In your case, the version might be different as the JDK will get updated in the future, but the process is exactly the same.

Screenshot--40-

Go into the bin folder.

Screenshot--41-

The binary files are kept here.

Screenshot--42-

We need to copy the directory path (directory address) of this folder.

Screenshot--43-

Simply copy the address using your mouse, or you can use the shortcut Ctrl + A for selecting all, and then use Ctrl + C for copying the directory.

Screenshot--44-

Go to the Control Panel.

Screenshot--45-

Go to System and Security.

Screenshot--47-

Click System.

Screenshot--49-

Click Advanced System Settings.

Screenshot--51-

Alternatively, you can hop into the Advanced System Settings by simply searching that from your taskbar.

Screenshot-2022-03-03-103840

Click Environment Variables.

Screenshot--53-

Select the Path and click Edit.

Screenshot--55-

Click New.

Screenshot--58-

A blank box will appear.

Screenshot--59--1

Paste the directory path.

Screenshot--60-

You can use the shortcut keys Ctrl + V for that as well.

Screenshot--61-

Click OK.

Screenshot--62-

Click OK.

Screenshot--64-

Click OK.

Screenshot--65-

How to Check if Java Was Installed Successfully

Open the terminal (CMD or PowerShell).

Screenshot--66-

Check the Java version using java --version.

Screenshot--68-

If it provides the version you have just installed, then you are good to go!

Screenshot--69-

Alternatively, you can simply run some Java code to check whether it is working or not. For now, I will execute a simple Hello World code in Java. I used notepad for now, but you can use any text editor you want.

Screenshot--70-

Compile your Java code using javac file_name_with_extension. Then run the class file using java file_name_without_extension.

Screenshot--71-

Wow! Everything is working perfectly. Your Windows machine is ready to execute any Java programs now.

I have also published a video on my English YouTube channel where I walk you through all of the processes mentioned above. You can also check that out here:

Conclusion

I hope this article helps you install Java on your Windows operating machine.

If you want to know how to install C and C++ compilers for your Windows operating system, then you can check this article.

If you want to know how to install Python on your windows, then you can check this article.

Thanks for reading the entire article. If it helps you then you can also check out other articles of mine at freeCodeCamp.

If you want to get in touch with me, then you can do so using Twitter, LinkedIn, and GitHub.

You can also SUBSCRIBE to my YouTube channel (Code With FahimFBA) if you want to learn various kinds of programming languages with a lot of practical examples regularly.

If you want to check out my highlights, then you can do so at my Polywork timeline.

You can also visit my website to learn more about me and what I'm working on.

Thanks a bunch!