Here you can find the source of getResource(Class _class, String resource)
static public URL getResource(Class _class, String resource)
//package com.java2s; import java.net.URL; public class Main { /** Find the requested resource (file) like Class.getResource(), but it works * for both applets and applications. Returns null if it cannot find the resource. *///from w ww .j a v a 2 s .co m static public URL getResource(Class _class, String resource) { URL url = _class.getResource(resource); if (url == null) { /* try { url = new URL(applet.getCodeBase() + resource); } catch (java.net.MalformedURLException e) { e.printStackTrace(); } */ } return url; } }