Reputation: 263
I have added java path in system variables, I tried to check java version by java -version
but I am not getting any error or any version :
Path Variables:
why the java -version command is not giving any result
Upvotes: 1
Views: 2690
Reputation: 1926
Temporary Solution if there is conflict in variables, like in my case i was having oracle path. Run in your command prompt Windows:
set PATH=C:\Program Files\Java\[jdk dir name]\bin;%PATH%
in my case it was as
set PATH=C:\Program Files\Java\jdk-17\bin;%PATH%
Permanent solution is to remove that extra unused path of jdk i.e .../orcale/... something in my case, i do not know if this aso apply for other type jdk paths
Upvotes: 1
Reputation: 263
I observed my Environment Variables , there are some of the paths added for Oracle :
i.e. C:\Program Files\Common Files\Oracle\Java\javapath
I have removed this paths as it was not in use. And it started showing me correct versions.
Upvotes: 4
Reputation: 1025
You have to restart your CMD window after changing the Environment variable. Please do so and retest.
If it's still not working, check in CMD if Java is on the PATH:
echo %PATH%
If it's on the PATH, then check if the path is actually correct:
"C:\Program Files\Java\jdk1.8.0_101\bin\java" -version
Upvotes: 2
Reputation: 107
Have you restarted your command windows since you added your environment variable ? They are loaded when the window is created and not updated after this.
Besides, what happens if you set manually your environment variable with set JAVA_HOME=<your_path>
? Does the java -version print any output ? You need to try that.
Upvotes: 1