Jar loader working with all java versions
This is a fusion fork of
- https://github.com/Exlll/JarLoader/tree/master
- https://github.com/Jebbike/JarLoader/blob/master/src/main/java/URLClassLoaderAccess.java
JarDependency dependency = new JarDependency(
"http://repo.exlll.de/configlib-core-2.2.0.jar",
Paths.get("dependency.jar")
).addDigest("MD5", "4f8245a58ac12c735d0b1f9ca42a0abe")
.addDigest("SHA-256", "6b598e77d1671...111373f9bcd10d");
JarLoader.download(dependency);
// or
JarLoader.downloadIfNotExists(dependency);
If the downloaded file is a Bukkit plugin, you can load it using:
Bukkit.getPluginManager().loadPlugin(...)
If the file is a library and not a Bukkit plugin, use the
ClassLoader
of your own plugin:
URLClassLoader loader = (URLClassLoader) plugin.getClassLoader();
JarLoader.load(dependency, loader);