Custom ClassLoader, how to use?

Viewed 15206

I am trying to use a custom class loader to load all the dependencies needed for the application. I've implemented the customerClassLoader following the site: https://www.javacodegeeks.com/2013/03/java-handmade-classloader-isolation.html

However, I dont understand how to tell my application to use the custom classLoader whenever needed.

For instance: Lets say, I have a method to make http request like below. How can I tell the application to use the custom classLoader to load the required jars?

private HttpResponse get() {
    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet(url);
    HttpResponse response = client.execute(request);
    return response;
}
1 Answers
Related