public static Image loadFromResource(String imageName, Class<?> cls) {
        try {
            final URL url = cls.getResource(imageName);

            if (url == null) {
                return null;
            }

            Image image = imageCache.get(url.toString());

            if (image == null) {
                image = Toolkit.getDefaultToolkit().createImage(url);
                imageCache.put(url.toString(), image);
            }

            return image;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
Loads an {@link Image} named <code>imageName</code> as a resource
relative to the Class <code>cls</code>.  If the <code>Image</code> can
not be loaded, then <code>null</code> is returned.  Images loaded here
will be added to an internal cache based upon the full {@link URL} to
their location.
<p>
<em>This method replaces legacy code from JDeveloper 3.x and earlier.</em></p>

@param imageName the name of the image
@param cls the class relative to the which the image resource should be obtained
@return the image

@see Class#getResource(String)
@see Toolkit#createImage(URL)
starter/src/main/java/org/jivesoftware/openfire/launcher/GraphicUtils.java