Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Friday, May 27, 2016

'C:\Program' is not recognized error

'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 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  

Answer by Adi Inbar for 'C:\Program' is not recognized error


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

Answer by DigCamara for 'C:\Program' is not recognized error


Even though Adi Inbar is pretty clear on the problem, I think his workaround isn't the best solution, because it tries to patch around the original problem: spaces in the path of your JDK installation.

The best way to solve your problem is actually reinstalling JDK to a space-less path. All other workarounds will cause you headaches in the long run.

Answer by adhg for 'C:\Program' is not recognized error


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'}

Answer by andrea for 'C:\Program' is not recognized error


Is the path you are setting the JAVA_HOME environment variable in a user variable or a system variable? You cannot use user variables within system variables. So if JAVA_HOME is defined as a user variable and you are adding it to your system path that won't work.

From the output of your set command it looks like %JAVA_HOME% is not being resolved. It should show the expanded version not the one with % signs in.

Add a Path user variable and add %JAVA_HOME%\bin to that. Windows will add your user path to the end of the system path.

You should not need quotes in the JAVA_HOME variable even if it contains spaces.

Answer by Ronak for 'C:\Program' is not recognized error


just add cd before adding the location eg: instead of

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

use

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

this helped me.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.