Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spark submit add multiple jars in classpath

I am trying to run a spark program where i have multiple jar files, if I had only one jar I am not able run. I want to add both the jar files which are in same location. I have tried the below but it shows a dependency error

spark-submit \   --class "max" maxjar.jar Book1.csv test \   --driver-class-path /usr/lib/spark/assembly/lib/hive-common-0.13.1-cdh​5.3.0.jar 

How can i add another jar file which is in the same directory?

I want add /usr/lib/spark/assembly/lib/hive-serde.jar.

like image 368
Avinash Nishanth S Avatar asked Mar 17 '15 12:03

Avinash Nishanth S


People also ask

How do I put multiple jars in spark shell?

You can also add jars using Spark submit option --jar , using this option you can add a single jar or multiple jars by comma-separated.

How do we submit JAR files in spark?

Only one is set through Spark submit and one via code. Choose the one which suits you better. One important thing to note is that using either of these options does not add the JAR file to your driver/executor classpath. You'll need to explicitly add them using the extraClassPath configuration on both.

What are jars in spark?

Spark JAR files let you package a project into a single file so it can be run on a Spark cluster. A lot of developers develop Spark code in brower based notebooks because they're unfamiliar with JAR files.


2 Answers

Just use the --jars parameter. Spark will share those jars (comma-separated) with the executors.

like image 54
pzecevic Avatar answered Sep 20 '22 23:09

pzecevic


Specifying full path for all additional jars works.

./bin/spark-submit --class "SparkTest" --master local[*] --jars /fullpath/first.jar,/fullpath/second.jar /fullpath/your-program.jar 

Or add jars in conf/spark-defaults.conf by adding lines like:

spark.driver.extraClassPath /fullpath/firs.jar:/fullpath/second.jar spark.executor.extraClassPath /fullpath/firs.jar:/fullpath/second.jar 
like image 43
user3688187 Avatar answered Sep 22 '22 23:09

user3688187