How To Set JAVA_HOME On Windows 10?
Có thể bạn quan tâm
This tutorial shows how to set the JAVA_HOME environment variable on Windows 10 or 11. Setting JAVA_HOME allows tools like Maven, Gradle, and IDEs to find and use your installed Java Development Kit (JDK).
Table of Contents
- 2. Open Environment Variables
- 3. Create JAVA_HOME Variable
- 4. Add JAVA_HOME to PATH
- 4.1 Older Windows Versions
- 4.2 Newer Windows 10/11
- 5. Test JAVA_HOME and Java
- 6. Why Set JAVA_HOME?
- 7. References
Technologies Used:
- Java 21
- Windows 10/11
In the Windows search bar (next to the Start button), type advanced system settings, and click View advanced system settings.
2. Open Environment Variables
In the System Properties window:
- Go to the Advanced tab
- Click the Environment Variables… button
3. Create JAVA_HOME Variable
In the System variables section:
- Click the New… button
- Set the Variable name to JAVA_HOME
- Set the Variable value to your JDK installation path (do not include the \bin folder)
Example: ✅ C:\Program Files\Java\jdk-21 ❌ C:\Program Files\Java\jdk-21\bin
4. Add JAVA_HOME to PATH
To make Java tools accessible from the command line, we must update the PATH variable.
4.1 Older Windows Versions
If you see a single-line text box, append this at the end of the value:
4.2 Newer Windows 10/11
If the editor shows a list, click New, and add:
5. Test JAVA_HOME and Java
Open Command Prompt and run:
java -version javac -version echo %JAVA_HOME% C:\Users\mkyon>java -version 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-LTS, mixed mode, sharing) C:\Users\mkyon>javac -version javac 21.0.8 C:\> echo %JAVA_HOME% C:\Program Files\Java\jdk-216. Why Set JAVA_HOME?
By setting JAVA_HOME:
- Java tools (like Maven, Gradle, and IDEs) can locate the JDK easily
- Java commands like java, javac, jstack, etc., are available system-wide
- It helps avoid conflicts between multiple Java versions
7. References
- How to Install Java on Windows (Step-by-Step Guide)
- How to Set $JAVA_HOME environment variable on macOS
- How to Open the Control Panel in Windows 10
Từ khóa » Cài đặt Java_home Windows 10
-
Cách đặt Biến Môi Trường JAVA_HOME Trong Windows 10 - Deft Blog
-
Cách đặt JAVA_HOME Trong Windows 10 - Windows789
-
Cài đặt Java Trên Windows - Openplanning
-
Blog: Cách đặt JAVA_HOME Trong Windows 10 - Begin-it
-
Cách đặt JAVA_HOME Trong Windows 10
-
Hướng Dẫn Cài đặt, Cấu Hình Và Thiết Lập Biến Môi Trường Cho Java
-
Cài đặt, Thiết Lập Biến Môi Trường Cho Java Trong Win 10 - 10AZ
-
How To Set Up JAVA_HOME In Window OS - Viblo
-
Hướng Dẫn Tải Và Cài đặt Java, Java JDK Cho Windows
-
Cài đặt Java Trên Windows 10 - CodeGym
-
Cài đặt JDK Và Cấu Hình Java Home Trên Windows - YouTube
-
Cài đặt Môi Trường Java
-
Hướng Dẫn Cách Cài đặt Java Trên Windows 11 - Blog Tips F4vnn
-
Biến Môi Trường để Cài đặt Java