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

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

问题描述

我最近尝试更改我的环境变量以设置 javac.exe 的路径(除其他外).它工作正常,直到突然间,我开始收到此错误.例如,我将 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 FilesJavajdk1.7.0_25

之后,我添加

%JAVA_HOME%in

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

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

'C:Program' 不是内部或外部命令、可操作的命令或批处理文件.

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

这个错误使它看起来像是遇到了程序文件"中的空间问题.不过,这很奇怪,因为它已经有一段时间没有这样做了,然后就开始了.此外,还有其他带有空格的变量可以正常工作.我试过删除变量并重新创建它,在 JAVA_HOME 周围加上引号(它转到正确的路径,但没有正确找到 javac.exe)..

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?

这是在 Windows 7 上.

This is on Windows 7.

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

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:UsersDemo_User_1AppDataRoaming pm;%JAVA_HOME%

C:UsersDemo_User_1AppDataRoaming pm; %JAVA_HOME%

JAVA_HOME 变量的定义如下:

where the JAVA_HOME variable is defined as such:

C:Program FilesJavajdk1.7.0_25

我通过命令提示符通过键入 %JAVA_HOME% 来测试变量的值,这就是我得到'C:Program' 无法识别..."的结果错误的地方

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..."

'set'的结果如下:

The results of 'set' are as follows:

C:UsersDemo_User_1>set
ALLUSERSPROFILE=C:ProgramData
ANDROID_HOME=C:UsersDemo_User_1DesktopAndroidadt-bundle-windows-x86_64-2013
0717sdk
APPDATA=C:UsersDemo_User_1AppDataRoaming
CommonProgramFiles=C:Program FilesCommon Files
CommonProgramFiles(x86)=C:Program Files (x86)Common Files
CommonProgramW6432=C:Program FilesCommon Files
COMPUTERNAME=DEMO_USER_1-HP
ComSpec=C:Windowssystem32cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=UsersDemo_User_1
JAVA_HOME=C:Program FilesJavajdk1.7.0_25
LOCALAPPDATA=C:UsersDemo_User_1AppDataLocal
LOGONSERVER=\DEMO_USER_1-HP
NUMBER_OF_PROCESSORS=4
OnlineServices=Online Services
OS=Windows_NT
Path=C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Clien
t;C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files
(x86)Common FilesMicrosoft SharedWindows Live;C:Windowssystem32;C:Windows;
C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program
Files (x86)Windows LiveShared;C:Program Files (x86)IntelOpenCL SDK2.0in
x86;C:Program Files (x86)IntelOpenCL SDK2.0inx64;C:Program FilesIntelI
ntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Managem
ent Engine ComponentsIPT;C:Program Files (x86)IntelIntel(R) Management Engin
e ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine Compone
ntsIPT;C:Program FilesIntelWiFiin;C:Program FilesCommon FilesIntelWir
elessCommon;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files
 (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows
Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110
ToolsBinn;C:Program Files
odejs; C:UsersDemo_User_1DesktopAndroidadt-b
undle-windows-x86_64-20130717sdk/platform-tools; C:UsersDemo_User_1DesktopA
ndroidadt-bundle-windows-x86_64-20130717sdk	ools; %JAVA_HOME%; %ANT_HOME%/bin
; C:Program FilesJavajdk1.7.0_25in; C:UsersDemo_User_1AppDataRoaming
p
m; "%JAVA_HOME%"; ;C:UsersDemo_User_1DesktopAndroidadt-bundle-windows-x86_6
4-20130717sdk/tools; C:UsersDemo_User_1DesktopAndroidadt-bundle-windows-x8
6_64-20130717sdk/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:Windowssystem32WindowsPowerShellv1.0Modules
PUBLIC=C:UsersPublic
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:Windows
TEMP=C:UsersDEMO_U~1AppDataLocalTemp
TMP=C:UsersDEMO_U~1AppDataLocalTemp
USERDOMAIN=Demo_User_1-HP
USERNAME=Demo_User_1
USERPROFILE=C:UsersDemo_User_1
VS110COMNTOOLS=C:Program Files (x86)Microsoft Visual Studio 11.0Common7Tools

windir=C:Windows
windows_tracing_flags=3
windows_tracing_logfile=C:BVTBinTestsinstallpackagecsilogfile.log

推荐答案

好的,这样说得更清楚了.

Okay, that makes it clearer.

这里有两个主要问题.

首先,您得到 'C:Program' is not configured... 的原因当然是因为它包含空格.您在 PATH 环境变量中引用它这一事实与 %JAVA_HOME% 在提示符下的解释方式无关.你有两个选择.

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. 在定义变量时引用它,即将JAVA_HOME设置为"C:Program FilesJavajdk1.7.0_25"
  2. 在调用时引用它.在提示符下键入 "%JAVA_HOME%in".当然,除非您以可执行文件(例如 "%JAVA_HOME%injavac.exe"),但你会看到它以这种方式抱怨 '"C:Program FilesJavajdk1.7.0_25"' 而不是 'C:Program'.
  1. Quote it when you define the variable, i.e. set JAVA_HOME to "C:Program FilesJavajdk1.7.0_25"
  2. Quote it when you invoke it. Type "%JAVA_HOME%in" 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%injavac.exe"), but you'll see that this way it complains about '"C:Program FilesJavajdk1.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%

会起作用,但那是因为 %JAVA_HOME% 在命令行中展开并且 PATH 设置为结果.如果您检查 PATH 的值,您会看到它以 C:Program FilesJavajdk1.7.0_25 结尾,而不是 %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 FilesJavajdk1.7.0_25, not %JAVA_HOME%.

此外,如果 javac.exebin 子目录中,您需要将其包含在路径中,即添加 ;C:ProgramFilesJavajdk1.7.0_25in 到路径.

Also, if javac.exe is in the bin subdirectory, you'll need to include that in the path, i.e. add ;C:Program FilesJavajdk1.7.0_25in to the path.

(顺便说一句,您在路径中有两次 %JAVA_HOME%,第二次之后还有一个额外的分号.)

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

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

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