Here you can find the source of loadImage(ClassLoader classLoader, String path)
public static BufferedImage loadImage(ClassLoader classLoader, String path)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; public class Main { public static BufferedImage loadImage(String path) { try {//from w w w . j ava 2 s . com URL url = ClassLoader.getSystemResource(path); if (url != null) { return ImageIO.read(url); } else { return null; } } catch (IOException e) { throw new RuntimeException("I/O error loading image " + path, e); } } public static BufferedImage loadImage(ClassLoader classLoader, String path) { try { URL url = classLoader.getResource(path); if (url != null) { return ImageIO.read(url); } else { return null; } } catch (IOException e) { throw new RuntimeException("I/O error loading image " + path, e); } } }