I want to set icon to my JFrame. I do the following:
Image icon = Toolkit.getDefaultToolkit().getImage(\"src/images/icon.jpg\"); this.setIconImage(icon);
Assuming your JAR file has a top level directory called images, you can use either:
images
getClass().getResource("/images/icon.jpg")
getClass().getClassLoader().getResource("images/icon.jpg")