BufferedImage img = ImageIO.read(<ClassName>.class.getClassLoader().getResource("path/to/resource"));
Wrong. Use this instead:
1
| BufferedImage img = ImageIO.read(getClass().getResource("/path/to/resource")); |
getClassLoader() does not work in unsigned applets -- this is the main reason that Class has the delegated getResource() method in the first place. Once you're no longer using getClassLoader directly, you need to write your absolute resource paths as an absolute path, or it will be relative to the package of the class. And since you're no longer relative to any package, you don't need to hardwire the class name in.