mdivk
mdivk

Reputation: 3727

How to add customized jar in Jupyter Notebook in Scala

I need to use a third party jar (mysql) in my Scala script, if I use spark shell, I can specify the jar in the starting command like below:

spark2-shell --driver-class-path mysql-connector-java-5.1.15.jar --jars /opt/cloudera/parcels/SPARK2/lib/spark2/jars/mysql-connector-java-5.1.15.jar

However, how can I do this in Jupyter notebook? I remember there is a magic way to do it in pyspark, I am using Scala, and I can't change the environment setting of the kernel I am using.

Upvotes: 2

Views: 5859

Answers (1)

mdivk
mdivk

Reputation: 3727

I have the solution now, and it is very simple indeed as below:

  1. Use a toree based Scala kernel (which is what I am using)
  2. Use AddJar: in the notebook and run it, the jar will be downloaded and voila!

That's it.

AddJar http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.15/mysql-connector-java-5.1.15.jar

Upvotes: 1

Related Questions