在Windows中使用cmd设置环境变量 [英] setting environmental variable in windows using cmd

查看:422
本文介绍了在Windows中使用cmd设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在Windows中启动我的项目,我必须使用以下命令在cmd中设置Java环境变量

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

之后它可以正常工作。

我的问题是为什么这两个命令不相等?

My question is why this both command are not equal?

推荐答案

set 命令知道空格。发出命令时

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

set JAVA_HOME = D:\Java\jdk1.7.0

您实际上将变量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.

这篇关于在Windows中使用cmd设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆