URLExtraLoader is a utility that allows you to quickly and easily create a URLClassLoader or work with an existing instance. Functions:
- Create your own URLClassLoader with dynamic modification of Classpath on the fly and control of resources loaded into Classpath.
- Extension of the standard URLClassLoader with a wrapper.
- A utility to work on the fly. It is sufficient to pass a reference to the loader object.
Default way to work with URLClassLoader. In this way, we cannot add files to Classpath.
URLClassLoader classLoader = new URLClassLoader(new URL[]{
new URL("file:\\test.jar")
});
URLExtraClassLoader
Extra extra = new ExtraURLClassloader(new URL[]{
new URL("file:\\test.jar")
});
We can now add and remove files to Classpath dynamically.
extra.add(new File("test.jar"));
Example of using the URLClassLoader wrapper
Extra extra = new URLClassloaderWrapper(new URLClassLoader(new URL[0]));
extra.add(new File("test.jar"));
You can also use ClasspathUtils.
Let's create a new instance of URLClassLoader and add a test jar file to Classpath.
URLClassLoader urlClassLoader = new URLClassLoader(new URL[0]);
ClasspathUtils.addToPath(new URL("file:\\test.jar"), urlClassLoader);
URLExtraLoader is an open source project distributed under the Apache License 2.0
- Download the latest build from releases
- Read the FAQ and examples
- Enjoy!
The project is in beta. Use at your own risk.