I am getting following error when running spark-shell command:
I have downloaded spark-2.1.1-bin-hadoop2.7.tgz
file from http://spark.apache.org/downloads.html, extracted the tar file and pasted the contents of the folder into c:\Spark
directory.
After that I have configured the environment variable for spark and jdk accordingly, but I am getting this error.
Launch Spark Shell (spark-shell) CommandGo to the Apache Spark Installation directory from the command line and type bin/spark-shell and press enter, this launches Spark shell and gives you a scala prompt to interact with Spark in scala language.
Using Spark shell To close Spark shell, you press Ctrl+D or type in :q (or any subset of :quit ).
Set SCALA_HOME in Control Panel\System and Security\System goto "Adv System settings" and add %SCALA_HOME%\bin in PATH variable in environment variables. Install Python 2.6 or later from Python Download link. Download SBT. Install it and set SBT_HOME as an environment variable with value as <<SBT PATH>> .
I resolved this error by using a short hand like "Progra~1" which is a short hand for "Program Files (x86)".
C:\Progra~1\Java\jdk1.8.0_161
I'm almost sure that your JAVA_HOME
environment variable contains a space that breaks spark-shell
. Please re-install Java to a directory with no spaces in the path.
You can see the relevant piece of code in bin/spark-class2.cmd that spark-shell
executes on Windows under the covers (through bin/spark-submit2.cmd shell script):
if "x%1"=="x" (
So when spark-class2.cmd
substitutes %1
to a path with a space (or something similar) it ends up as:
if "x"Files\Java\jdk1.8.0_45""=="x" (
that gives the error due to too many double quotes.
The mystery is how does the JAVA_HOME
end up in this place. I can't seem to find the reason, but that's what we see here.
You can see this issue when your Java home set like following in windows
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_162\bin
Issue here is space in "Program Files (x86)" If you add double quotes will not work on window 10
"C:\Program Files (x86)\Java\jdk1.8.0_162\bin"
You need to copy Java into outside Program Files (x86) then it should work
JAVA_HOME=C:\java\jdk1.8.0_171\bin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With