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

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

Variable 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
🌐
Oracle
java.com › en › download › help › path.html
How do I set or change the PATH system variable?
The PATH system variable can be set using System Utility in control panel on Windows, or in your shell's startup file on Linux and Solaris.
🌐
IBM
ibm.com › docs › en › b2b-integrator › 6.2.0
Setting Java variables on Windows
JAVA_HOME and PATH variables are required for the operating system to find the required Java programs and utilities.
🌐
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 1: Open a Command Prompt window. ... Step 2: You should see the path to your Java installation printed in the Command Prompt.
🌐
Medium
azimuahamed.medium.com › java-environment-variables-setup-windows-11-58fe71e43b5e
JAVA Environment Variables Setup Windows 11 | by Azim Uddin Ahamed | Medium
August 1, 2024 - In the Environment Variables window, under the “System variables” section, click “New.” · For the “Variable name,” enter JAVA_HOME. For the “Variable value,” enter the path to your JDK installation directory.
🌐
TheServerSide
theserverside.com › feature › How-to-set-JAVA_HOME-in-Windows-and-echo-the-result
How to set JAVA_HOME in Windows | TheServerSide
The PATH variable points to \bin, while JAVA_HOME points to the root folder into which the JDK was installed. For those who prefer to use the command line, you can easily set JAVA_HOME on Windows with any terminal window, be it PowerShell, the ...
Find elsewhere
🌐
Medium
programming-tech.medium.com › how-to-path-set-java-in-windows-10-download-and-install-java-3af92d60e631
How to Path set java in windows 10? Download and Install java | by Programming tech | Medium
May 13, 2021 - In this tutorial I will show you how to set JAVA Path in PATH variable as environment variable in Windows 10 operating system.
🌐
Javatutorial
javatutorial.net › set-java-home-windows-10
How to set JAVA_HOME in Windows 10 | Java Tutorial Network
In Windows 10 press Windows key + Pause Key, This will open the System Settings window. Go to Change settings and select the Advanced tab. ... The service for java script on the website selling generic medicines online is very well implemented. ... Under “System variables” click the “New…” button and enter JAVA_HOME as “Variable name” and the path to your Java JDK directory under “Variable value”
🌐
LYRASIS Wiki
wiki.lyrasis.org › display › FEDORA34 › Setting+JAVA_HOME+in+Windows
Setting JAVA_HOME in Windows - Fedora 3.4 Documentation - LYRASIS Wiki
Using File Explorer, open the directory C:\Program Files\Java. Inside that path will be one or more sub-directories such as jdk1.5.0_17. If you have just installed the Java Development Kit, it will be installed to the newest directory, which you can find by sorting by date.
🌐
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 - In the Environment Variables window, locate the System variables section and find the Path variable. Select Path and click Edit. Add Java Path.
🌐
Android Developers
developer.android.com › android studio › sdkmanager
sdkmanager | Android Studio | Android Developers
Note: If you want to install packages for an operating system different from the current machine, set the REPO_OS_OVERRIDE environment variable to either "windows", "macosx", or "linux". Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 2495532 › how-do-i-set-up-a-path-variable-for-the-java-comma
How do I set up a path variable for the java command javac? - Microsoft Q&A
Java.com: Support Options: http://www.java.com/en/download/support.jsp ... <start><control panel><system><advanced system settings> enter admin P/W if prompted <Environment variables> This gives the basic idea - http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx - (note 'my computer' - 'computer', 'advanced' - 'Advanced system settings')
🌐
Specinnovations
help.specinnovations.com › configuring-java-home-on-windows
Configuring JAVA_HOME Environment Variable on Windows
Paste the copied JDK path (e.g., C:\Program Files\Java\jdk-17) into the Variable value field. ... Click OK to close the Edit or New System Variable dialog. Click OK again to close the Environment Variables dialog, and then OK to close the System Properties window.
🌐
Selenium
selenium.dev › downloads
Downloads | Selenium
To use the Java SNAPSHOT versions, you will need to add the snapshot repository .
🌐
JavaFX
openjfx.io
JavaFX
JavaFX, also known as OpenJFX, is free software; licensed under the GPL with the class path exception, just like the OpenJDK.
🌐
Quora
quora.com › How-do-I-set-the-path-in-Java-using-CMD
How to set the path in Java using CMD - Quora
Answer (1 of 4): Your question is not clear but do you mean path to java home directory ? Or the path variable in a Java application ? on Windows set JAVA_HOME=javahome then set “PATH=%JAVA_HOME%\bin;%PATH%” on Linux set JAVA_HOME=javahome then set PATH=$JAVA_HOME/bin:$PATH
🌐
Oracle
java.com › en › download › help › version_manual.html
How to find Java version in Windows or Mac - Manual method
In order to use the command line tools, you will need to download the Java Development Kit (JDK). The JRE and JDK are separate and can coexist on your system. Only one JRE can be installed on Mac. There can be multiple JDKs installed on a system, as many as you wish. Type the following in a Terminal window: /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version