Here you can find the source of getResource(String name)
public static URL getResource(String name)
//package com.java2s; //License from project: Open Source License import java.net.URL; public class Main { /** Resources are those stored in the class path (e.g., src/main/resources). */ public static URL getResource(String name) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); return loader.getResource(name); }//from w w w .j a v a 2 s . c om }