A class loader that can be created on a Java 7 (JSR-203) file system path. This is very similar to URLClassLoader
except that it works on any file system. URLClassLoader
only works when a corresponding URLStreamHandler
is installed which is hard to do in a non-intrusive way.
This class loader does not work with Spring resource scanning because the way Spring resource scanning is implemented it works only for folders and JAR files.
ClassLoader classLoader = new PathClassLoader(aPath);
The constructor argument aPath
is expected to be a folder. If you have the classes in a JAR create a Zip File System. If you run into Bug 8004789 use the backport for JDK7.
You can optionally pass in a parent ClassLoader
in this case parent-first classloading will be used (Java SE default).
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>path-classloader</artifactId>
<version>1.0.0</version>
</dependency>