Reputation: 161
I have set my java environment variables as described:
under System variables i have the following:
Variable : JAVA_HOME
and the values for this as : C:\Program Files\Java\jdk1.7.0_80
and the variable 'path
' i have added the same file path as that of JAVA_HOME
that is : C:\Program Files\Java\jdk1.7.0_80
but when i check my java version from command prompt it shows: java version 1.8.0_152
.
what am in doing wrong. I have both jdk 1.8
and 1.7
installed in my machine. I am working on windows 10 - 64 bit machine
Upvotes: 1
Views: 7790
Reputation: 3914
You should set the variable path till bin
directory
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_80
PATH : %JAVA_HOME%\bin
Explanation
To compile and run a java
program we use javac
and java
commands.But these commands are unknown to your OS
until we explicitly specify the location of these executable files. This is the main reason why we need to set path in Java and while specifying the path we specify the path of bin
folder which contains the executable files.
Upvotes: 2