Here is an example:
String path = "resources/something.png"; BufferedImage img = ImageIO.read(getClass().getClassLoader().getResource(path));
To do this in a static context, for example, in a static initializer block:
String path = "resources/something.png"; BufferedImage img = ImageIO.read(className.class.getClassLoader().getResource(path));
source share