Load the image file from a folder or a jar file: use javax.imageio.ImageIO class to read the image file
import java.awt.image.BufferedImage; import javax.imageio.ImageIO; public class Main { public static void main(String[] args) throws Exception { BufferedImage image = ImageIO.read(Main.class.getResource("S.jpg")); } }