getResource() uses the classpath to find the resource. Make sure the image file is in a folder on the classpath.