Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ClassLoader and class path
package classloader;
public class ShowClassLoader {
public static void main(String[] args) throws Exception {
ClassLoader classloader = ShowClassLoader.class.getClassLoader();
InputStream streamFromCurrentClassLoader = classloader.getResourceAsStream("classloader/");
InputStream streamFromParentClassLoader = classloader.getParent().getResourceAsStream("classloader/");
System.out.println("Stream from current " + streamFromCurrentClassLoader);
// Output null !
System.out.println("Stream from parent " + streamFromParentClassLoader);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment