• Post Reply Bookmark Topic Watch Topic
  • New Topic

JAVA_HOME set but I can't access the exacutables form other directories  RSS feed

 
Adi Florescu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hy!

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?
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adi - Welcome to the Ranch...

you should have specified JAVA_HOME as a user variable. Try changing it to a system variable (Environmental Variables settings).
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adi Florescu wrote:Take a look at my console output:

That doesn't tell us much. You also need to show us what 'echo %JAVA_HOME%' shows.

Winston
 
Adi Florescu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )?
 
Roberto Perillo
Bartender
Posts: 2273
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Adi!

Well, you set your %JAVA_HOME% variable with your JDK directory. You appended %JAVA_HOME%\bin to your Path variable. This should be enough already.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


1) ItDoesntWorkIsUseless.

2) TellTheDetails.

3) You need %JAVA_HOME%\bin in your PATH, not %JAVA_HOME% in your PAHT.
 
Adi Florescu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Jeff thanks for the tips, I edited the post.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
echo %PATH%
Look closely at what's there and make sure it's what you expect.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!