Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does spark-shell fail with "'""C:\Program' is not recognized as an internal or external command" on Windows?

While running the following command prompt I am getting the error as in the screenshot.

screenshot

Command:

c:\spark>spark-shell

Error:

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

Why?

like image 298
Suprit Gandhi Avatar asked May 19 '17 09:05

Suprit Gandhi


Video Answer


3 Answers

Suprit,

The issue is most likely with the space in your JAVA_HOME. If the path contains spaces, use the shortened path name. For example, C:\Progra~1\Java\jdk1.8.0_131

If you are using Windows10. please try the below

Set JAVA_HOME as "C:\Progra~1\Java\jdk1.8.0_131"

Also make sure you have included %JAVA_HOME%\bin in your PATH environment variable.

like image 159
Sid Avatar answered Oct 22 '22 21:10

Sid


I suspect that you installed Java to a directory with a space so JAVA_HOME breaks spark-shell script on Windows.

Make sure you install Java to a directory with no space in the path.


The other option would be to set JAVA_HOME to the same value but wrapped with double quotes, e.g.

set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_131"

That will likely lead to the other issue on Windows that was answered in Why does spark-shell fail with "was unexpected at this time"? that's simply to re-install Java to a directory with no space in the path.


The thing I could not check out yet would be to wrapped JAVA_HOME using single quotes (not double quotes). That in theory would help pass the line with comparison to "x".

like image 44
Jacek Laskowski Avatar answered Oct 22 '22 21:10

Jacek Laskowski


First you gotta find out where is your JAVA_HOME. In my case it is, "C:\Program Files\Java\jdk1.8.0_25\bin\java"

Then open your file called spark-class2.cmd, locate and change to your java home path (change only the bold text below).

Additional text are included for completeness only.

"C:\Program Files\Java\jdk1.8.0_25\bin\java" -Xmx128m -cp "%LAUNCH_CLASSPATH%" org.apache.spark.launcher.Main %* > %LAUNCHER_OUTPUT% for /f "tokens=*" %%i in (%LAUNCHER_OUTPUT%) do ( echo %%i set SPARK_CMD=%%i ) del %LAUNCHER_OUTPUT% %SPARK_CMD%

like image 2
kepung Avatar answered Oct 22 '22 22:10

kepung