To read it any resource from classpath, you need to provide the path relative to JAR starting with "/". Example, let's you have jar "test.jar" and inside that you have any class in com.test.package.Testing.class so to get this class as resource you need to use path
"/com/test/package.Testing.class"
You can always get a resource as stream which is loaded in JVM. For example you have bundled your image file in your jar which is in your classpath.
First get the input stream of image file as resource by using
Inputstream is = AnyClassWhichIsInSamejar.class.getClass().getResourceAsStream("/sprites/bg.png");
or
getClass().getResourceAsStream("/sprites/bg.png");
Now convert this input stream in your ImageIcon object