Here's an example:
String path = "resources/something.png";
BufferedImage img = ImageIO.read(getClass().getClassLoader().getResource(path));
To do it in a static context, like in a static initializer block:
String path = "resources/something.png";
BufferedImage img = ImageIO.read(className.class.getClassLoader().getResource(path));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…