Reputation: 1101
I have JAVA_HOME variable in System variables and is set to
C:\Program Files\Java\jdk1.8.0_60
I get an error when I try to use command %JAVA_HOME%
C:/Program is not recognized as an internal or external command.
I understand it is because of space in the path after Program,
I have also tried using quotes across the path but it did not resolve the issue.
i.e
"C:\Program Files\Java\jdk1.8.0_60"
but no help.
Edit: I tried removing ones with Program Files at all.
Now my System path variable looks like this:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
Environment path variable looks like this:
C:\Users\dev4\AppData\Roaming\npm; C:\mongodb\bin;
So, I do not really see any of these with space or program files in path and yet when I try
%Path%
it gives the same error.
EDIT 2:
cd %PATH% gives The file name or extension is too long.
however cd %JAVA_HOME% works
Edit 3: Now, the PATH variable has location fo JDK bin but none of my java commands are recognized
Upvotes: 1
Views: 12576
Reputation: 849
For all general case use the short folder path.
the short form folder name can be obtained by executing cmd prompt
and visiting the parent directory and type dir /x
and press enter you will see the short form of sub folder names
ex:- C:/Progra~1/MARIAD~1.2/bin/mysql.exe
in the place of
C:/Program Files/MariaDB 10.2/bin/mysql.exe
here short form of MariaDB 10.2 can be obtained form visiting c:/program files/ in cmd prompt and type dir /x
Upvotes: 0
Reputation: 3372
wrapping the variables in double quotes should work
"%JAVA_HOME%\bin\java"
Or if you host supports it use a short name
C:\Progra~1\Java\jdk1.8.0_60
Upvotes: 4