For JAVA_HOME it should be C:\java, but on your Path variable, it should point to C:\java\bin\ since Path is what is used to tell the Command Prompt where to look for executables.
cmd - what should be the java path in the environment variable on my system Windows 10 - Stack Overflow
How to set the environment variables for Java in Windows - Stack Overflow
path - Setting up enviroment variables in Windows 10 to use java and javac - Stack Overflow
%JAVA_HOME% and %Path% variables set correctly. Java returning wrong version.
Videos
Java SE Development Kit 8u112 on a 64-bit Windows 7 or Windows 8
Set the following user environment variables (== environment variables of type user variables)
JAVA_HOME :C:\Program Files\Java\jdk1.8.0_112JDK_HOME :%JAVA_HOME%JRE_HOME :%JAVA_HOME%\jreCLASSPATH :.;%JAVA_HOME%\lib;%JAVA_HOME%\jre\libPATH :your-unique-entries;%JAVA_HOME%\bin(make sure that the longishyour-unique-entriesdoes not contain any other references to another Java installation folder.
Note for Windows users on 64-bit systems:
Progra~1 = 'Program Files'
Progra~2 = 'Program Files(x86)'
Notice that these environment variables are derived from the "root" environment variable JAVA_HOME. This makes it easy to update your environment variables when updating the JDK. Just point JAVA_HOME to the fresh installation.
There is a blogpost explaining the rationale behind all these environment variables.
Optional recommendations
- Add a user environment variable
JAVA_TOOL_OPTIONSwith value-Dfile.encoding="UTF-8". This ensures that Java (and tools such as Maven) will run with aCharset.defaultCharset()ofUTF-8(instead of the defaultWindows-1252). This has saved a lot of headaches when wirking with my own code and that of others, which unfortunately often assume the (sane) default encoding UTF-8. - When JDK is installed, it adds to the system environment variable
Pathan entryC:\ProgramData\Oracle\Java\javapath;. I anecdotally noticed that the links in that directory didn't get updated during an JDK installation update. So it's best to removeC:\ProgramData\Oracle\Java\javapath;from thePathsystem environment variable in order to have a consistent environment.
In Windows inorder to set
Step 1 : Right Click on MyComputer and click on properties .
Step 2 : Click on Advanced tab
Step 3: Click on Environment Variables

Step 4: Create a new class path for JAVA_HOME

Step 5: Enter the Variable name as JAVA_HOME and the value to your jdk bin path ie c:\Programfiles\Java\jdk-1.6\bin and
NOTE Make sure u start with .; in the Value so that it doesn't corrupt the other environment variables which is already set.

Step 6 : Follow the Above step and edit the Path in System Variables add the following ;c:\Programfiles\Java\jdk-1.6\bin in the value column.
Step 7 :Your are done setting up your environment variables for your Java , In order to test it go to command prompt and type
java
who will get a list of help doc
In order make sure whether compiler is setup Type in cmd
javac
who will get a list related to javac
Hope this Helps !
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
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
