×

注意!页面内容来自https://mkyong.com/java/how-to-install-java-on-windows-step-by-step-guide/,本站不储存任何内容,为了更好的阅读体验进行在线解析,若有广告出现,请及时反馈。若您觉得侵犯了您的利益,请通知我们进行删除,然后访问 原网页

How to Install Java on Windows (Step-by-Step Guide)

Java 21 is the latest Long-Term Support (LTS) releaserecommended for most new projects. Oracle Java is the default for most enterprise environmentswhile Eclipse Temurin is popular in the open-source community or where licensing flexibility is required.

Table of contents

Technologies used:

  • Oracle Java 21 LTS
  • Eclipse Temurin Java 21 LTS
  • Windows 10/11

1. How to Install Oracle Java 21 on Windows

1.1 Download Oracle Java

Firstwe visit the official Oracle Java Downloads page. We select Windows as our operating system and download the .msi installer.

install oracle java

1.2 Run the Oracle Java Installer

We double-click the downloaded .msi file. The installation wizard guides us through the process:

  • Accept the license agreement.
  • Choose or confirm the installation path (default is C:\Program Files\Java\jdk-21).
  • Click "Install" and wait for the process to finish.

install oracle java msi

1.3 Verify Java Installation

To verify that Java was installed successfullywe open Command Prompt and run:


java -version

We should see output similar to:


java version "21.0.8" 2025-07-15 LTS
Java(TM) SE Runtime Environment (build 21.0.8+12-LTS-250)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.8+12-LTS-250mixed modesharing)

1.4 Set the JAVA_HOME Environment Variable

Setting the JAVA_HOME variable allows other software to detect our Java installation. Here’s how we do it:

  1. Right-click This PC > Properties > Advanced system settings.
  2. Click Environment Variables.
  3. Under System variables click New:
    • Variable name: JAVA_HOME
    • Variable value: C:\Program Files\Java\jdk-21
  4. Find the Path variableclick Editand add %JAVA_HOME%\bin.
  5. Click OK to save and restart the Command Prompt.

Note
For a detailed walkthroughsee: How to set JAVA_HOME on Windows

2. How to Install Eclipse Temurin Java 21 on Windows

Eclipse Temurin is a freeopen-source build of OpenJDK and widely used in the Java community.

2.1 Download Eclipse Temurin JDK

We visit the official Temurin JDK Release Page and download the Windows installer (.msi).

install Temurin java

2.2 Run the Temurin Installer

We double-click the downloaded filefollow the wizardaccept the licenseand select the installation path. The installer typically sets the JAVA_HOME variable for us automatically. If promptedwe restart Windows.

install Temurin java msi

2.3 Verify Temurin Java Installation

Open Command Prompt and run:


java -version

We should see output similar to:


openjdk version "21.0.8" 2025-07-15 LTS
OpenJDK Runtime Environment Temurin-21.0.8+9 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.8+9 (build 21.0.8+9-LTSmixed modesharing)

2.4 Check JAVA_HOME Environment Variable

The Temurin installer usually configures JAVA_HOME and updates the Path variable automatically. To verify:

  1. Open System Properties > Advanced > Environment Variables.
  2. Ensure the JAVA_HOME variable points to the correct folderfor example: C:\Program Files\Eclipse Adoptium\jdk-21.0.8.9-hotspot\
  3. Make sure %JAVA_HOME%\bin is included in the Path.

Note
For a detailed walkthroughsee: How to set JAVA_HOME on Windows

3. Frequently Asked Questions (FAQ)

Q1: Do we need to uninstall old Java versions before installing Java 21?
It is recommended but not required. We can keep multiple versionsbut make sure the JAVA_HOME and Path variables point to the desired version.

Q2: Is Oracle Java free for personal use?
YesOracle Java is free for personal use. For commercial usealways check the official Oracle licensing page.

4. References

mkyong

Founder of Mkyong.compassionate Java and open-source technologies. If you enjoy my tutorialsconsider making a donation to these charities.

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments