'C:\Program'无法识别错误 [英] 'C:\Program' is not recognized error

查看:214
本文介绍了'C:\Program'无法识别错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近尝试更改我的环境变量来设置javac.exe的路径(除其他外)。它工作正常,直到突然间,我开始得到这个错误。例如,我宣布一个JAVA_HOME变量为



C:\Program Files\Java\jdk1.7.0_25



之后添加



%JAVA_HOME%\bin



到PATH变量,但这给我一个错误:


'C:\Program'不被识别为内部或外部命令,可操作的命令或批处理文件。


这个错误使它看起来像在程序文件中的空间遇到问题。这是奇怪的,但是,由于它不是一个好时机,所以开始了。此外,还有其他变量,其中的空格工作正常。我已经尝试删除变量并重新创建它,将引号放在JAVA_HOME(正确的路径,但没有找到javac.exe正确)..



任何提示我可以做什么?



这是在Windows 7上。



编辑:



环境变量是通过控制面板>高级系统设置>环境变量进行设置的。通过使用资源管理器窗口复制我想要的文件夹的地址来设置变量的值。我将它添加到PATH环境变量中,通过在前面的变量和分号之间添加一个空格,如下所示:



C:\Users\Demo_User_1\AppData\Roaming\\\
pm; %JAVA_HOME%



JAVA_HOME变量定义如下:



C:\Program Files\Java\jdk1.7.0_25



我通过测试变量的值一个命令提示符通过键入%JAVA_HOME%,这是我得到的结果错误'C:\Program'不能被识别...



结果的'set'如下:

  C:\Users\Demo_User_1> set 
ALLUSERSPROFILE = C: \ProgramData
ANDROID_HOME = C:\Users\Demo_User_1\Desktop\Android\adt-bundle-windows-x86_64-2013
0717\sdk
APPDATA = C: \Users\Demo_User_1\AppData\Roaming
CommonProgramFiles = C:\Program Files\Common Files
CommonProgramFiles(x86)= C:\Program Files(x86)\Common Files
CommonProgramW6432 = C:\Program Files\Common文件
COMPUTERNAME = DEMO_USER_1-HP
ComSpec = C:\Windows\system3 2\cmd.exe
FP_NO_HOST_CHECK = NO
HOMEDRIVE = C:
HOMEPATH = \Users\Demo_User_1
JAVA_HOME = C:\Program Files\Java\ jdk1.7.0_25
LOCALAPPDATA = C:\Users\Demo_User_1\AppData\Local
LOGONSERVER = \\DEMO_USER_1-HP
NUMBER_OF_PROCESSORS = 4
OnlineServices =在线服务
OS = Windows_NT
Path = C:\Program文件(x86)\Intel\iCLS Client\; C:\Program Files\Intel\iCLS Clien
t\; C:\Program Files\Common Files\Microsoft Shared\Windows Live; C:\Program文件
(x86)\Common Files\Microsoft Shared\Windows Live; C :\Windows\system32; C:\Windows;
C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Program
文件(x86)\ Windows Live\Shared; C:\程序文件(x86)\Intel\OpenCL SDK\2.0\bin\
x86; C:\Program文件(x86)\Intel\ OpenCL SDK\2.0\bin\x64; C:\Program Files\Intel\I
ntel(R)管理引擎组件\DAL; C:\Program Files\Intel\ Intel(R)Managem
ent Engine Components\IPT; C:\Program Files(x86)\Intel\Intel(R)Management Engin
e Components\DAL; C:\Program文件(x86)\Intel\Intel(R)管理引擎Compone
nts\IPT; C:\Program Files\Intel\WiFi\bin\; C:\Program Files\\ \\Common Files\Intel\Wir
elessCommon\; C:\Program Files\Microsoft\Web Platform Installer\; C:\Program Files
(x86)\Microsoft ASP.NET\ASP .NET Web页面\v1.0 \; C:\程序文件(x86)\Windows
Kits \8.0 \Windows Performance Toolkit \; C:\Program Files \Microsoft SQL Server\110\
Tools\Binn\; C:\Program Files\\\
odejs\; C:\Users\Demo_User_1\Desktop\Android\adt-b
undle-windows-x86_64-20130717\sdk / platform-tools; C:\Users\Demo_User_1\Desktop\A
ndroid\adt-bundle-windows-x86_64-20130717\sdk\tools; %JAVA_HOME%; %ANT_HOME%/ bin
; C:\Program Files\Java\jdk1.7.0_25\bin; C:\Users\Demo_User_1\AppData\Roaming\\\
p
m; %JAVA_HOME%; ; C:\Users\Demo_User_1\Desktop\Android\adt-bundle-windows-x86_6
4-20130717\sdk / tools; C:\Users\Demo_User_1\Desktop\Android\adt-bundle-windows-x8
6_64-20130717\sdk / platform-tools
PATHEXT = .COM; .EXE ;. BAT; .CMD; .VBS; .VBE; .JS; .JSE; .WSF; .WSH; .MSC
PCBRAND = Pavilion
平台= MCD
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 58 Stepping 9,GenuineIntel
PROCESSOR_LEVEL = 6
PROCESSOR_REVISION = 3a09
ProgramData = C:\ProgramData
ProgramFiles = C:\Program Files
ProgramFiles(x86)= C:\Program文件(x86)
ProgramW6432 = C:\Program文件
PROMPT = $ P $ G
PSModulePath = C:\Windows\\ \\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC = C:\Users\Public
SESSIONNAME =控制台
SystemDrive = C:
SystemRoot = C:\Windows
TEMP = C:\Users\DEMO_U〜1\AppData\Local\Temp
TMP = C:\Users\DEMO_U〜1\AppData\\ % b USERPROFILE = C:\Users\Demo_User_1
VS110COMNTOOLS = C:\Program文件(x86)\Microsoft Visual Studio 11.0\Common7\Tools
\
windir = C:\Windows
windows_tracing_flags = 3
windows_tracing_logfile = C:\BVTBin\Tests\installpackage\csilogfile.log


解决方案

好的,这使得它更清楚。



有两个主要问题



首先,你得到'C:\Program'的原因无法识别... 当然是因为它包含空格。您在PATH环境变量中引用的事实与提示时如何解释%JAVA_HOME%无关。你有两个选择。


  1. 定义变量时引用它,即将 JAVA_HOME 设置为C: \Program Files\Java\jdk1.7.0_25

  2. 当你调用它时引用它。在提示符下键入%JAVA_HOME%\bin。当然,除非您以可执行文件结束路径(例如%JAVA_HOME%\bin\,否则您将获得未被识别为内部或外部命令,可操作的程序或批处理文件错误) javac.exe),但你会看到这样的方式,它抱怨'C:\Program Files\Java\jdk1.7.0_25'而不是'C:\Program'

其次,您不能使用环境变量路径。当您在命令提示符下设置路径时,您可以使用环境变量。例如,

 设置PATH =%PATH%;%JAVA_HOME%
pre>

将工作,但这是因为%JAVA_HOME%在命令行中展开, PATH 设置为结果。如果您检查 PATH 的值,您会看到它以 C:\Program Files\Java\jdk1.7.0_25 结尾,而不是 %JAVA_HOME%



另外,如果 bin> 子目录中的需要在路径中加入,即将; C:\Program Files\Java\jdk1.7.0_25\bin 添加到路径。 p>

(BTW,路径中有%JAVA_HOME%两次,第二个之后还有一个额外的分号。)


I've recently tried changing my environment variables to set paths to javac.exe (among other things). It was working fine until, all of a sudden, I started getting this error. For example, I declared a JAVA_HOME variable to be

C:\Program Files\Java\jdk1.7.0_25

After which, I add

%JAVA_HOME%\bin

to the PATH variable, but this gives me an error:

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

This error makes it seem like it's running into problems with the space in "Program Files". This is weird, though, since it wasn't doing this for a good while, then started. Further, there are other variables with spaces in them that work just fine. I've tried deleting the variable and recreating it, putting quotes around JAVA_HOME (which goes to the correct path, but does not find javac.exe correctly)..

Any tips on what I might do?

This is on Windows 7.

EDIT:

The environment variables were set by going Control Panel > Advanced System Settings > Environment Variables. The value of the variables were set by copying the address of the folder I want through an Explorer window. I added it to the PATH environment variable by appending the address with a space between the preceding variable and a semicolon at the end, as such:

C:\Users\Demo_User_1\AppData\Roaming\npm; %JAVA_HOME%

where the JAVA_HOME variable is defined as such:

C:\Program Files\Java\jdk1.7.0_25

I test the value of the variable through a command prompt by typing %JAVA_HOME%, and that's where I get the resulting error of "'C:\Program' is not recognized..."

The results of 'set' are as follows:

C:\Users\Demo_User_1>set
ALLUSERSPROFILE=C:\ProgramData
ANDROID_HOME=C:\Users\Demo_User_1\Desktop\Android\adt-bundle-windows-x86_64-2013
0717\sdk
APPDATA=C:\Users\Demo_User_1\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=DEMO_USER_1-HP
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\Demo_User_1
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_25
LOCALAPPDATA=C:\Users\Demo_User_1\AppData\Local
LOGONSERVER=\\DEMO_USER_1-HP
NUMBER_OF_PROCESSORS=4
OnlineServices=Online Services
OS=Windows_NT
Path=C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Clien
t\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files
(x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;
C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\
x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\I
ntel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Managem
ent Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engin
e Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Compone
nts\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\Wir
elessCommon\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
 (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows
Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\
Tools\Binn\;C:\Program Files\nodejs\; C:\Users\Demo_User_1\Desktop\Android\adt-b
undle-windows-x86_64-20130717\sdk/platform-tools; C:\Users\Demo_User_1\Desktop\A
ndroid\adt-bundle-windows-x86_64-20130717\sdk\tools; %JAVA_HOME%; %ANT_HOME%/bin
; C:\Program Files\Java\jdk1.7.0_25\bin; C:\Users\Demo_User_1\AppData\Roaming\np
m; "%JAVA_HOME%"; ;C:\Users\Demo_User_1\Desktop\Android\adt-bundle-windows-x86_6
4-20130717\sdk/tools; C:\Users\Demo_User_1\Desktop\Android\adt-bundle-windows-x8
6_64-20130717\sdk/platform-tools
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PCBRAND=Pavilion
Platform=MCD
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=3a09
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\DEMO_U~1\AppData\Local\Temp
TMP=C:\Users\DEMO_U~1\AppData\Local\Temp
USERDOMAIN=Demo_User_1-HP
USERNAME=Demo_User_1
USERPROFILE=C:\Users\Demo_User_1
VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools
\
windir=C:\Windows
windows_tracing_flags=3
windows_tracing_logfile=C:\BVTBin\Tests\installpackage\csilogfile.log

解决方案

Okay, that makes it clearer.

There are two main problems here.

First of all, the reason you're getting 'C:\Program' is not recognized... is, of course, because it contains spaces. The fact that you have it quoted in the PATH environment variable has no relation to how %JAVA_HOME% is interpreted at the prompt. You have two options.

  1. Quote it when you define the variable, i.e. set JAVA_HOME to "C:\Program Files\Java\jdk1.7.0_25"
  2. Quote it when you invoke it. Type "%JAVA_HOME%\bin" at the prompt. Of course, you'll get the "not recognized as an internal or external command, operable program or batch file" error unless you end the path with an executable (e.g. "%JAVA_HOME%\bin\javac.exe"), but you'll see that this way it complains about '"C:\Program Files\Java\jdk1.7.0_25"' rather than 'C:\Program'.

Second, you can't use environment variables in the path. You can use environment variables when you set the path at the command prompt. For example,

set PATH=%PATH%;%JAVA_HOME%

will work, but that's because %JAVA_HOME% is expanded at the command line and PATH is set to the result. If you check the value of PATH, you'll see that it ends with C:\Program Files\Java\jdk1.7.0_25, not %JAVA_HOME%.

Also, if javac.exe is in the bin subdirectory, you'll need to include that in the path, i.e. add ;C:\Program Files\Java\jdk1.7.0_25\bin to the path.

(BTW, you have %JAVA_HOME% in the path twice, and there's an extra semicolon after the second one.)

这篇关于'C:\Program'无法识别错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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