I can’t believe that for more than 4 years no one has answered this question correctly.
https://docs.oracle.com/javase/8/docs/api/java/lang/ClassLoader.html
The ClassLoader class uses a delegation model to search for classes
and resources. Each instance of ClassLoader has an associated parent
class loader. When requested to find a class or resource, a
ClassLoader instance will delegate the search for the class or
resource to its parent class loader before attempting to find the
class or resource itself. The virtual machine’s built-in class loader,
called the “bootstrap class loader”, does not itself have a parent but
may serve as the parent of a ClassLoader instance.
Sergei, the problem with your example was that Library 1,2 & 3 were on the default class path, so the Application classloader which was the parent of your URLClassloder was able to load the classes from Library 1,2 & 3.
If youremove the libraries from the classpath, the Application classloader won’t be able to resolve classes from them so it will delegate resolvation to its child – the URLClassLoader. So that is what you need to do.