https://github.com/exlll/jarloader
Library for loading jar dependencies at runtime
https://github.com/exlll/jarloader
Last synced: 11 months ago
JSON representation
Library for loading jar dependencies at runtime
- Host: GitHub
- URL: https://github.com/exlll/jarloader
- Owner: Exlll
- License: mit
- Created: 2018-09-16T20:44:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-01T09:15:52.000Z (over 7 years ago)
- Last Synced: 2025-05-07T00:32:45.919Z (about 1 year ago)
- Language: Java
- Size: 56.6 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Usage
#### 1. Define a dependency
```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");
```
#### 2. Download the jar
```java
JarLoader.download(dependency);
// or
JarLoader.downloadIfNotExists(dependency);
```
#### 3. Load the jar
If the downloaded file is a Bukkit plugin, you can load it using:
```java
Bukkit.getPluginManager().loadPlugin(...)
```
If the file is a library and not a Bukkit plugin, use the
`ClassLoader` of your own plugin:
```java
URLClassLoader loader = (URLClassLoader) plugin.getClassLoader();
JarLoader.load(dependency, loader);
```