1

I wrote a spark program in scala. now I want to run the script I wrote, in terminal. in pyspark I use spark-submit for a python file. now I want to do the same for my scala program. I do not want to use Intellij or write my program in spark-shell. I just want to write my code in an editor and run it by using a command in terminal. is that possible? Thank you in advance

1

1 Answer 1

2

Create a JAR file for your code (jar name is HelloWorld.jar) say . You can use HDFS or local path like below examples.

You can add lot options in below commands which you can found in the url given by philantrovert in comments.

Run in Local mode.

spark-submit --class path.to.YourMainClass  --master local[*] /path/to/your/jar/HelloWorld.jar

Run in cluster mode.

spark-submit --deploy-mode cluster --class path.to.YourMainClass  --master yarn hdfs://nameservice1/hdfsPath/to/your/jar/HelloWorld.jar
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. and what "path.to.YourMainClass" is exactly? what should I palce instead of it?
It should be your complete package name of the class with your class name
If your package in which you created your program is org.myprograms and your main class is MainClass.... give org.myprograms.MainClass

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.