I have a rather strange problem. I have set my JAVA_HOME correctly and added it in my PATH environment variable like this %JAVA_HOME%\bin, but when I type java in my command prompt it doesn't work. However it does work if I type the full path like this: %JAVA_HOME%\bin\java.
Take a look at my console output:
Why is this happening, and how should I fix it?
you should have specified JAVA_HOME as a user variable. Try changing it to a system variable (Environmental Variables settings).
Adi - Welcome to the Ranch...
Thanks! Good to be here!
My JAVA_HOME is currently set up as a system variable, so I didn't have to change it
Here it is:
I noticed that if I append %java_home%\bin to the PATH, then it actually works. So it's a temporary fix until I restart my system. The question remains why this happens and how to fix it permanently?
Adi Florescu wrote:So it's a temporary fix until I restart my system. The question remains why this happens and how to fix it permanently?
Whenever you set the path you have to open a new command prompt to make it work. Isn't that working for you now (might be since you restarted the system )?
Adi Florescu wrote:
I have a rather strange problem. I have set my JAVA_HOME correctly and added it in my PAHT enviroment variable but when I type java in my command prompt it doesn't work.
3) You need %JAVA_HOME%\bin in your PATH, not %JAVA_HOME% in your PAHT.
Jeff thanks for the tips, I edited the post.
Adi Florescu wrote:Well, what I have now works to some extent, i. e. I can access javac, but after I restart my computer, I still need to add %java_home%/bin one more time to the PATH variable. I still don't understand why I need to do that since is already added to begin with. I suspect that other problems are related to this PATH thing, but I can live with that for now.
First, make sure that in the Environment Variables section of your System control panel, you have set PATH to include %JAVA_HOME%\bin, not just %JAVA_HOME%.
Second, There's a user section and a system section for env vars. I don't really know what the difference is (though I can make an educated guess I suppose), but I always put mine in the System section.
Third, make sure you hit Apply or whatever to make sure it accepts your changes.
And finally, after you do all that, start up a new cmd window and execute
Look closely at what's there and make sure it's what you expect.