Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I set JAVA_HOME to the full path of the Java home directory by command :

C:\Users\trainee7>setx JAVA_HOME "C:\Program Files\Java\jdk1.6.0_21"

and result was:

SUCCESS: Specified value was saved.
After I for confirmation I entered command :

C:\Users\trainee7>%JAVA_HOME%\bin\java -version

but it doesn't work, got result as error :

C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Why this? And what can I do for setting JAVA_HOME to java library?
Posted

I haven't used "setx" myself but a doc page at http://ss64.com/nt/setx.html[^] says:
Quote:
Because SETX writes variables to the master environment in the registry, edits will only take effect when a new command window is opened - they do not affect the current CMD or PowerShell session.


In other words, after setting the value with 'setx', you need to discard the window you are in and open a new one.
 
Share this answer
 
C:\Users\trainee7>"%JAVA_HOME%"\bin\java -version
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900