def load_jar_class(jar_path, class_name): """ Load a class at runtime directly from a jar file. Note that with some libraries this can cause problems because the library will not be *visible* to the default class loader. :param jar_path: Path to the `.jar` file. :param class_name: The fully qualified Class Name within the jar to load. :return: """ URL = JClass('java.net.URL') URLClassLoader = JClass('java.net.URLClassLoader') Class = JClass('java.lang.Class') UrlArray = JArray(URL) urls = UrlArray(1) urls[0] = get_url(jar_path) java_class = JClass(Class.forName(class_name, True, URLClassLoader(urls))) return java_class