Windows 11 Community

Cover image for How to Install Java on Windows 11?
Muhammed Cetin
Muhammed Cetin

Posted on • Updated on

How to Install Java on Windows 11?

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

  1. Check If Java is Already Installed
  2. How to Download Java?
  3. How to Install Java?
  4. How to Configure Environment Variables for Java?

1. Check If Java is Already Installed

  1. Open Start Menu and type CMD. Then click on it on the search results.

  2. Type java -version command and hit Enter. If you see java 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 see java 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.
    java -version

  3. Type javac --version command on Command Prompt and hit Enter. If you see a response like javac 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.
    javac -version


2. How to Download Java?

  1. Go to Oracle Download page: https://www.oracle.com/java/technologies/javase-downloads.html

  2. 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.
    JDK Download

  3. 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.
    Download JDK Installer .exe

  4. You'll see a disabled download button on the pop-up.
    Accept Oracle License Agreement

  5. Check the checkbox that I've shown below to accept the license agreement. Then click the download button.
    Download JDK

  6. Click Save file.
    Save Java Installer


3. How to Install Java?

  1. Double-click on the downloaded file to start the installation.
    Double-click on the installer

  2. Since the installation needs administrator privileges, Windows 11 want to confirm to run it. Click Yes.

  3. Click Next.
    Next

  4. 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 click Next.
    Specify the location

  5. The installation will start.
    Java

  6. Click Close.

  7. Java is installed correctly. 👏 Now, follow the next step to configure environment variables for Java.


4. How to Configure Environment Variables for Java?

  1. 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 following C:\Program Files\Java\jdk-version-you-installed\ path if you want.
    Java Path

  2. 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.
    Open Environment variables settings

  3. Click Environment Variables.
    Open Environment variables

  4. Click New under System variables section.
    Add a new System variable

  5. Type JAVA_HOME in Variable name field, and type the path where Java is located in the Variable value field. Then click OK.
    JAVA_HOME

  6. Now, we'll verify whether JAVA_HOME is available. To do that, open Command Prompt again by searching for cmd on Start Menu. Don't use the old window, please, because changes on environment variables require restarting Command Prompt.

  7. Type echo %JAVA_HOME%, and press Enter. If you see a result like the one below, everything is OK. Otherwise, delete the variable and try to set it again.
    Verify JAVA_HOME

  8. Now, we'll add Java binaries as Path variables. To do that, go back to the environment variables window.

  9. Find Path variable under System variables section by scrolling down. Click on it to select. Then click Edit.
    Path variable

  10. 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. Click OK and close the window.
    If JAVA binary path is already defined

  11. 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 hit Enter. Then click OK.
    Define Java Path with JAVA_HOME

  12. Close the windows related to environment variables.

  13. Open Command Prompt again and type java -version and javac -version commands, respectively.

  14. You'll see the version numbers of both, like the image below.
    Verify java and javac

  15. 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

  1. Is it free to download or install Java on Windows 11?

    Yes, it is free.

  2. Is it official the installation file that we've downloaded?

    Yes, it is official, of course. We've downloaded it from Oracle's website.

  3. Is Java safe to install?

    Yes, it is safe.

  4. Which Java version is best for Windows 11?

    Java SE 16.01 or later

  5. How do I know if Java is installed on Windows 11?

    Open Command Prompt, then type java -version and javac -version commands, respectively.

  6. Where is Java located on Windows 11?

    C:\Program Files\Java

  7. 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.


References

Discussion (0)