2

To start the my project in windows i have to set the java environmental variable in cmd using below command

set JAVA_HOME = D:\Java\jdk1.7.0

but it didn't set the environment variable, i don't know what the issue.After pending couple hours i find the reason that is due to white space on both side of = symbol.Because of this environmental variable not getting set and i changed by command to

set JAVA_HOME=D:\Java\jdk1.7.0

after that it is working fine.

My question is why this both command are not equal?

0

1 Answer 1

4

The set command is aware of spaces. When you issue the command

set JAVA_HOME = D:\Java\jdk1.7.0

you actually set the variable JAVA_HOME␣ to value ␣D:\Java\jdk1.7.0. Note the spaces: !

You can check it using the following way:

> echo [%JAVA_HOME%]
[%JAVA_HOME%]
> echo [%JAVA_HOME %]
[ D:\Java\jdk1.7.0]

The brackets are included in order to highlight spaces, they are not important by themselves.

Sign up to request clarification or add additional context in comments.

1 Comment

Being able to put spaces in the variable name isn't very useful, but has to remain possible for backwards compatibility. On the other hand, it is important to be able to put spaces in the variable value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.