Dynamically loading JAR file in Zeppelin

Imagine that you need to load JAR file dynamically in Zeppelin working on your EMR cluster. One easy way is to deploy the file to the instance and load it from there, however, what can you do if you have almost no access to the cluster and the filesystem? You can load the JAR from S3 and load it dynamically via custom classloader.

First, load the file:

Next, implement the classloader:

It extracts JAR from byte array and goes through the resources. Finally, just create the class:

Of course, using this instance will be harder as it is loaded in different classloader so you will probably need a lot of reflection.