How to load Classes at runtime from a folder or JAR?
The following code loads all classes from a JAR file. It does not need to know anything about the classes. The names of the classes are extracted from the JarEntry. JarFile jarFile = new JarFile(pathToJar); Enumeration<JarEntry> e = jarFile.entries(); URL[] urls = { new URL(“jar:file:” + pathToJar+”!/”) }; URLClassLoader cl = URLClassLoader.newInstance(urls); while (e.hasMoreElements()) { … Read more