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 OverflowJust 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
Here are the typical steps to set JAVA_HOME on Windows 10.
- Search for Advanced System Settings in your windows Search box. Click on Advanced System Settings.
- Click on Environment variables button: Environment Variables popup will open.
- Goto system variables session, and click on New button to create new variable (HOME_PATH), then New System Variables popup will open.
- Give Variable Name: JAVA_HOME, and Variable value : Your Java SDK home path. Ex: C:\Program Files\java\jdk1.8.0_151 Note: It should not include \bin. Then click on OK button.
- Now you are able to see your JAVA_HOME in system variables list. (If you are not able to, try doing it again.)
- Select Path (from system variables list) and click on Edit button, A new pop will opens (Edit Environment Variables). It was introduced in windows 10.
- Click on New button and give %JAVA_HOME%\bin at highlighted field and click Ok button.
You can find complete tutorials on my blog :
How to set JAVA_HOME in 64 bit Windows 10 OS
Videos
I need help finding the location of my java_home/bin
"Start" > "Control Panel" > "Java".
Select "Java" tab.

Click "View"
Look in the "Path" column for version of the JRE you have installed.

In the above example the "Path" contains:
C:\apps\jdk\jre\bin\javaw.exe
JAVA_HOME should point to the root directory of the Java installation,
so in this case:
C:\apps\jdk
And the PATH should contain JAVA_HOME\bin, in this case:
C:\apps\jdk\bin
From a command prompt we can set these values using the following commands:
setx JAVA_HOME C:\apps\jdk
setx PATH C:\apps\jdk\bin;%PATH%
Notes:
- Modify the above commands as appropriate for your Java installation.
- These are
SystemnotUserenvironment variables.
See Installing the JDK Software and Setting JAVA_HOME and PATH and CLASSPATH for more information.
On your keyboard click the windows key and q and search java. Then in the apps section next to about java click the arrow and click open file location. You are here at the file location
If this does not work for you you maybe don't have windows or you have an old version of it or if you have windows and the latest version of windows then I don't know what is wrong.
I need to setup a task on a few machines with apps that require the correct Java version path in their environment variables.
This was suggested, but requires some work apparently:
Remove-PathFolders -Folders “\Java\jdk” -EnvironmentVariableTarget $([System.EnvironmentVariableTarget]::Machine) $jdkDp = (Get-ChildItem -Path “C:\Program Files (x86)\Java\jdk*” | Sort-Object name | Select-Object -Last 1).FullName Add-PathFolders -Folders $($jdkDp + "\bin") -EnvironmentVariableTarget $([System.EnvironmentVariableTarget]::Machine) Get-PathFolders -EnvironmentVariableTarget $([System.EnvironmentVariableTarget]::Machine)
Are you required to use PowerShell to accomplish this?
I’m not against it, I’m just curious.
It would be wise to backup your current path before executing the change.