Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

windows - 'C:Program' is not recognized error

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

After which, I add

%JAVA_HOME%in

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

where the JAVA_HOME variable is defined as such:

C:Program FilesJavajdk1.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: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-20130717sdkools; %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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yet another solution is to do this: C:Program Files has a short name

C:Progra~1

in windows.

so simply write Progra~1 instead of the Program Files. {added missing 'r'}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...