I have a JAR file with java classes, which I want to use in my scala application. I don't want to add the JAR to the lib/ folder because I do not want to rebuild my scala application every time the JAR is changed.
So I tried my hands with scala reflections and class loaders and I was able to load the class, but I don't know how to use the methods of the class further in my scala application.
Here is my attempt so far,
var classLoader = new java.net.URLClassLoader(Array(new File("java-module.jar").toURI.toURL),this.getClass.getClassLoader)
var javaClass = classLoader.loadClass("com.sample.myClass")
How can I go further to create an object of this particular class and use it's methods?
Aucun commentaire:
Enregistrer un commentaire