The resource is looked up by a predefined list of classloaders:
Handler
's own classloaderOne can customize this order by setting its own classloader to ClasspathStreamHandlerFactory.primaryClassLoader.
Classloader will be used to load the resource before any method of the URL object is executed.
Simply creating an URL object of "classpath:" protocol would not cause any resource lookups.
Using this protocol handler is possible via two ways:
URLStreamHandlerFactory
main(String[])
or other simillar place:
URL.setURLStreamHandlerFactory( new ClasspathStreamHandlerFactory() );
This method can be called at most once in a given Java Virtual Machine.
The URLStreamHandlerFactory
instance is used to construct a stream protocol handler from a protocol name.
If there is a security manager, this method first calls the security manager's checkSetFactory
method to ensure the operation is allowed. This could result in a SecurityException.
java -Djava.protocol.handler.pkgs=net.sf.fikin.net.protocols ...
If there are other values set to that propery, use "|" as an delimiter.