Create a gist now

Instantly share code, notes, and snippets.

ClassLoader and class path
package classloader;
import java.io.InputStream;
public class ShowClassLoader {
public static void main(String[] args) throws Exception {
ClassLoader classloader = ShowClassLoader.class.getClassLoader();
InputStream streamFromCurrentClassLoader = classloader.getResourceAsStream("classloader/test.properties");
InputStream streamFromParentClassLoader = classloader.getParent().getResourceAsStream("classloader/test.properties");
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