samedi 19 mai 2018

Java, Load classes from JAR to use them later

I have a problem loading class from JAR file.

I can load them with URLClassLoader using a JarFile etc etc like in this answer; but if later in code I try to instantiate them with reflection:

Object obj = Class.forName(className).newInstance()

I get a ClassNotFoundException. Can I dinamically load a class to use them later, when I need them, just like classes in ClassPath? Thank you!





Aucun commentaire:

Enregistrer un commentaire