In this tutorial, I'm going to show you how to install Java and configure its environment variables on Windows 11, including JAVA_HOME.
Even if you don't have any idea about how to complete these tasks, thanks to the clear explanations and screenshots for each step, you'll be able to install Java completely.
Let's start. 🤞
Sections
- Check If Java is Already Installed
- How to Download Java?
- How to Install Java?
- How to Configure Environment Variables for Java?
1. Check If Java is Already Installed
Open Start Menu and type
CMD
. Then click on it on the search results.Type
java -version
command and hitEnter
. If you seejava is not recognized as an internal or external command, operable program or batch file
response like on the image below, it means Java isn't installed on your Windows 11. However, if you seejava version 16.0.1...
response, it means you already have Java. In this case, run the command in 3rd step to check whether javac is already installed.
Type
javac --version
command on Command Prompt and hitEnter
. If you see a response likejavac 16.0.1
, you already have Java on your PC, and you don't need to install it again. Otherwise, continue to follow the installation steps.
2. How to Download Java?
Go to Oracle Download page: https://www.oracle.com/java/technologies/javase-downloads.html
On this page, there are some downloadable Java versions. We'll download the latest version where is at the top of the page. When I'm writing this guide, the latest version of Java is SE 16. Click
JDK Download
link to start the download.
On this page, there are different installation files of Java for different operating systems. Scroll down to show the download links. Since we'll install it on Windows 11, we need to download .exe file that I've marked. Click on it.
Check the checkbox that I've shown below to accept the license agreement. Then click the download button.
3. How to Install Java?
Double-click on the downloaded file to start the installation.
Since the installation needs administrator privileges, Windows 11 want to confirm to run it. Click
Yes
.Note the destination folder because we need it when configuring environment variables. Since we've downloaded the 64-Bit installation file, Java will be installed on
C:\Program Files\Java\jdk-version-number\
location. Ensure you've noted this location. Then clickNext
.
Click
Close
.Java is installed correctly. 👏 Now, follow the next step to configure environment variables for Java.
4. How to Configure Environment Variables for Java?
Open File Explorer and paste the location where Java was installed, and you've noted before. Then hit
Enter
to go there. You also can go there by followingC:\Program Files\Java\jdk-version-you-installed\
path if you want.
We'll define this path as our JAVA_HOME environment variable now. Open Start Menu and type
environment variables
. Then click on it on the search results.
Type
JAVA_HOME
inVariable name
field, and type the path where Java is located in theVariable value
field. Then clickOK
.
Now, we'll verify whether
JAVA_HOME
is available. To do that, open Command Prompt again by searching forcmd
on Start Menu. Don't use the old window, please, because changes on environment variables require restarting Command Prompt.Type
echo %JAVA_HOME%
, and pressEnter
. If you see a result like the one below, everything is OK. Otherwise, delete the variable and try to set it again.
Now, we'll add Java binaries as Path variables. To do that, go back to the environment variables window.
Find
Path
variable underSystem variables
section by scrolling down. Click on it to select. Then clickEdit
.
Now, you may see
C:\Program Files\Common Files\Oracle\Java\javapath
variable has already been set. If so, you don't need to change anything in this window. ClickOK
and close the window.
Otherwise, you need to add it manually. Click
New
on the right side of the window. An empty text field will be created at the bottom of the list. Type%JAVA_HOME%/bin
there and hitEnter
. Then clickOK
.
Close the windows related to environment variables.
Open
Command Prompt
again and typejava -version
andjavac -version
commands, respectively.You'll see the version numbers of both, like the image below.
That's all. 😊
Conclusion
If you've followed all steps carefully, you can run Java programs or games on Windows 11. However, if you're in trouble with Java installation or usage, feel free to ask for help by using the discussion form below. I'll try to answer your questions within the same day. 🤞
FAQ
-
Is it free to download or install Java on Windows 11?
Yes, it is free.
-
Is it official the installation file that we've downloaded?
Yes, it is official, of course. We've downloaded it from Oracle's website.
-
Is Java safe to install?
Yes, it is safe.
-
Which Java version is best for Windows 11?
Java SE 16.01 or later
-
How do I know if Java is installed on Windows 11?
Open Command Prompt, then type
java -version
andjavac -version
commands, respectively. -
Where is Java located on Windows 11?
C:\Program Files\Java
-
Should I remove Java from Windows 11?
If you have enough free disk space, you shouldn't remove it. Java is one of the most common programming languages, and you might need to run a Java program in your Windows 11 later.
Top comments (8)
I feel this is outdated because I watched another guide. I opened everything you showed in this guide but I've had issues after the video guide also (everything in the video worked, ended off with "just open files with java now"). I would hope you could update this and hope it could work for me? I've been trying to install java for 3 and a half days now.
every time I type ‘javac-version’ it says javac is not recognized, everything else showed up like it should. When trying to run programs through java it says ‘unable to install Java’ although it’s been installed it.
I have this issue as well. any advice?
Great work man. Thanks so much
I complete all procedures as indicated above, but I fail to the program(java program).
please help me
please, help me to create shortcut on the desktop
@Muhammed Cetin
Followed the steps perfectly, but im only getting the correct response for java -version but for javac -version it is saying javac is not recognized as a command