Just set the path variable to JDK bin in environment variables.

CopyVariable Name : PATH 
Variable Value : C:\Program Files\Java\jdk1.8.0_31\bin

But the best practice is to set JAVA_HOME and PATH as follow.

CopyVariable Name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.8.0_31

Variable Name : PATH 
Variable Value : %JAVA_HOME%\bin
Answer from isurujay on Stack Overflow
🌐
Java2Blog
java2blog.com › home › core java › java path › how to set java path in windows 10
How to set java path in windows 10 - Java2Blog
January 11, 2021 - Double click on the empty row and add %JAVA_HOME%\bin. Here, % symbol is used to locate JAVA_HOME environemt variable and \bin provides location for java.exe and h=javac.exe · Close the command prompt and launch again.
🌐
Support Your Tech
supportyourtech.com › home › articles › how to set java path in windows 10 using command prompt: a quick guide
How to Set Java Path in Windows 10 Using Command Prompt: A Quick Guide
August 26, 2024 - Navigate to this directory through the File Explorer to confirm its location. Set the path temporarily using the Command Prompt by entering set PATH=%PATH%;C:Program FilesJavajdk-xx.x.x_xxbin.
🌐
UMA Technology
umatechnology.org › home › how to set java path in windows 10 using command prompt: a quick guide
How to Set Java Path in Windows 10 Using Command Prompt: A Quick Guide - UMA Technology
June 24, 2025 - Common default locations include: ... Opening File Explorer and navigating to C:Program FilesJava or C:Program Files (x86)Java. Running the command where java in Command Prompt after Java is already installed and added to Path (if possible). ... This is the directory you will add to your Windows ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-set-java-path-in-windows-and-linux
How to Set Java Path in Windows and Linux? - GeeksforGeeks
July 23, 2025 - Step 2: You should see the path to your Java installation printed in the Command Prompt.
🌐
Oracle
java.com › en › download › help › path.html
How do I set or change the PATH system variable?
In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.
🌐
Mkyong
mkyong.com › home › java › how to set java_home on windows (step-by-step guide)
How to Set JAVA_HOME on Windows (Step-by-Step Guide) - Mkyong.com
July 29, 2025 - Try to write command in “Command Prompt” insted of Powershell ... instead of adding %JAVA_HOME%\bin to the system variable, I put the whole path like C:\Program Files\Java\jdk1.8.0_201\bin and it worked ...
🌐
TutorialsPoint
tutorialspoint.com › how-to-set-temporary-and-permanent-paths-in-java
How to set Temporary and Permanent Paths in Java?\\n
There are two ways to set the path in java, First is Temporary Path and second is Permanent Path. ... Write in the command prompt: SET PATH=C:\Program Files\Java\jdk_version\bin and hit enter command.
🌐
Atlassian
confluence.atlassian.com › doc › setting-the-java_home-variable-in-windows-8895.html
Setting the JAVA_HOME Variable in Windows | Confluence Data Center 10.2 | Atlassian Documentation
setx /m JAVA_HOME "C:\Program Files\Java\jdk11.0.17.8" Restart Command Prompt to reload the environment variables then use the following command to check the it's been added correctly. ... You should see the path to your JDK (or JRE) installation.
Find elsewhere
🌐
TheServerSide
theserverside.com › feature › How-to-set-JAVA_HOME-in-Windows-and-echo-the-result
How to set JAVA_HOME in Windows | TheServerSide
To echo JAVA_HOME in a DOS prompt, simply bookend the variable with percentage signs, like so: @REM How to echo JAVA_HOME in windows echo %JAVA_HOME% >> C:\_jdk25.0 · If you use a Bash shell, or if you have set JAVA_HOME in an Ubuntu environment and need to echo JAVA_HOME in Linux, place a single dollar sign before the environment variable: echo $JAVA_HOME. If the echo command returns the value you set for JAVA_HOME, you know your system is configured properly.
🌐
C# Corner
c-sharpcorner.com › article › how-to-set-up-the-java-path-on-windows
How to Set Up the Java Path on Windows
December 27, 2024 - The topic "How to Set Up the Java Path on Windows" covers the essential steps needed to configure your system so that Java commands can be run from anywhere in the command line.
🌐
Sololearn
sololearn.com › en › Discuss › 480306 › how-i-set-java-path-in-my-pc-windows-10-
How I set java path in my pc windows 10 ? | Sololearn: Learn to code for FREE!
June 21, 2017 - 2. Click Environment Variables. ... 3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. ... 4. Reopen Command prompt window, and run your java code.
🌐
CodeJava
codejava.net › java-core › how-to-set-environment-variables-for-java-using-command-line
How to set environment variables for Java using command line
April 9, 2020 - But that isn’t cool, because I’m about to show you how to do the same thing using command line prompt as shown below (Windows 7, 8 and 10): setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0" setx PATH "%PATH%;%JAVA_HOME%\bin";The setx command permanently updates the environment variables.
🌐
TunesBro
tunesbro.com › home › how to set java 11 path on windows 10
How to Set Java 11 Path on Windows 10
July 19, 2023 - For example, if the JDK 11 is installed in the "C:\Program Files\Java\jdk-11" directory, you would enter "C:\Program Files\Java\jdk-11" as the variable value. 7. Click on the "OK" button to save the changes and close all the dialog boxes. 8. In the Environment Variables dialog box, scroll down to the "Path" variable under the "System variables" section, and click on the "Edit" button. 9. In the Edit Environment Variable dialog box, click on the "New" button. ... 12. Open the command prompt and type "java -version" to verify that the Java version is displayed correctly.
🌐
Javatutorial
javatutorial.net › set-java-home-windows-10
How to set JAVA_HOME in Windows 10 | Java Tutorial Network
Hi, Thank you for the instruction ...jdk1.8.0_201 as its value. Then edit PATH and add %JAVA_HOME%\bin as a new path. Then in command prompt I typed echo %JAVA_HOME% ....
🌐
Quora
quora.com › How-do-I-set-a-Java-path-in-Windows-10
How to set a Java path in Windows 10 - Quora
Answer: 1. You need to paste in web search field: “How do I set a Java path in Windows 10?” 2. Then from first link on the result list you can get: How to set JAVA_HOME in Windows 10 3. Open that link and follow steps: > 1. Open Advanced System Settings In Windows 10 press Windows key + Pause...
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-set-temporary-and-permanent-paths-in-java
How to Set Temporary and Permanent Paths in Java? - GeeksforGeeks
May 12, 2025 - Copy the path of jdk/bin directory (e.g. C:\Program Files\Java\jdk-24\bin) In the Command Prompt, write the following command
🌐
The Windows Club
thewindowsclub.com › the windows club › general › how to set java_home in windows 11/10
How to set JAVA_HOME in Windows 11/10
Now go back to the Environment Variable window and select Path under the System variable. Click on Edit button to open Edit environment variable window. Click on New button and type %JAVA_HOME%\bin.
Published   July 13, 2024