Issue
I've seen some Spring code that read config files and other resources directly off the runtime classpath using the classpath:/some/path/to/resource
URL protocol.
Is this a Spring construct or a Java construct?
I can't find any documentation besides this question - URL to load resources from the classpath in Java, which doesn't indicate either way.
If it's a Java construct, can anyone point me to its official documentation?
Solution
Well you can always register URL handlers. Java also has a file:/// and jar: handler. Also class.getResource will by default read from the classpath.
http://code.google.com/p/madura-classpath-protocol-handler/
apparently it is a spring feature.
"You can see these standard handlers, and associated implementation classes,in the JDK's RT.JAR file. Look for classes whose fully-qualified name starts with sun.net.www.protocol.For example,the class sun.net.www.protocol.http.Handler defines the HTTP protocol handler. Class sun.net.www.protocol.ftp.Handler defines the FTP protocol handler class."
http://java.sun.com/developer/onlineTraining/protocolhandlers/
Trying to use classpath:
in Java 1.6 results in:
Exception in thread "main" java.net.MalformedURLException: unknown protocol: classpath
Answered By - Markus Mikkolainen
Answer Checked By - David Goodson (JavaFixing Volunteer)