urlclassloader-util

Utilities for manipulating sun.misc.URLClassPath-based ClassLoaders

License

License

GroupId

GroupId

org.danilopianini
ArtifactId

ArtifactId

urlclassloader-util
Last Version

Last Version

0.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

urlclassloader-util
Utilities for manipulating sun.misc.URLClassPath-based ClassLoaders
Project URL

Project URL

https://github.com/DanySK/urlclassloader-util
Source Code Management

Source Code Management

https://github.com/DanySK/urlclassloader-util

Download urlclassloader-util

How to add to project

<!-- https://jarcasting.com/artifacts/org.danilopianini/urlclassloader-util/ -->
<dependency>
    <groupId>org.danilopianini</groupId>
    <artifactId>urlclassloader-util</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.danilopianini/urlclassloader-util/
implementation 'org.danilopianini:urlclassloader-util:0.1.1'
// https://jarcasting.com/artifacts/org.danilopianini/urlclassloader-util/
implementation ("org.danilopianini:urlclassloader-util:0.1.1")
'org.danilopianini:urlclassloader-util:jar:0.1.1'
<dependency org="org.danilopianini" name="urlclassloader-util" rev="0.1.1">
  <artifact name="urlclassloader-util" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.danilopianini', module='urlclassloader-util', version='0.1.1')
)
libraryDependencies += "org.danilopianini" % "urlclassloader-util" % "0.1.1"
[org.danilopianini/urlclassloader-util "0.1.1"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
commons-io : commons-io jar 2.5

Project Modules

There are no modules declared in this project.

URLClassLoader util

Utilities for manipulating sun.misc.URLClassLoaders

Status

Stable branch

Build Status

Development branch

Build Status

Usage

You can add and remove entries for the classloader of your preference. Entries must be java.net.URLs (or java.net.URIs, or java.io.Files, or java.lang.Strings that can be transformed to URLs). The ClassLoader must have a field of type URLClassPath, that is what this library actually manipulates.

Please be wary that, despite being designed with some degree of reliability in mind, this library accesses non-public APIs, and as such may work only on a subset of Java Runtime Environments, and newer versions of working JREs may break it. The library is tested against multiple JREs, please refer to the Travis CI build to verify that the JRE you are interested in is currently supported.

Example with system ClassLoader

// Also URL, URI, or File are ok
final String myDir = ...;
URLClassLoaderUtil.addFirst(myDir);
URLClassLoaderUtil.remove(myDir);
URLClassLoaderUtil.addLast(myDir);

Example with the current class ClassLoader

final ClassLoader cl = MyClass.class.getClassLoader();
// Also URL, URI, or File are ok
final String myDir = ...;
URLClassLoaderUtil.addFirst(myDir, cl);
URLClassLoaderUtil.remove(myDir, cl);
URLClassLoaderUtil.addLast(myDir, cl);

Import URLClassLoader util in your project

I warmly suggest to use Gradle, Maven or a similar system to deal with dependencies within your project. In this case, you can use this product by importing the following Maven dependency:

<dependency>
    <groupId>org.danilopianini</groupId>
    <artifactId>urlclassloader-util</artifactId>
    <version>VERSION_YOU_WANT_TO_USE</version>
</dependency>

or the following Gradle dependency:

compile 'org.danilopianini:urlclassloader-util:VERSION_YOU_WANT_TO_USE'

Alternatively, you can grab the latest jar and throw it in your classpath. In this case, be sure to include the dependencies of this project in your classpath as well.

Versions

Version
0.1.1
0.1.0