public static Version ofJar(Class cls)
    {
        String url = null;
        
        // Construct the path to the class file and get its URL.
        // E.g. /org/apache/wicket/Component.class
        String path = "/" + cls.getName().replaceAll("\\.", "/") + ".class";
        URL classRsrc = cls.getResource(path);

        if(classRsrc != null)
        {
            // If if the class was in a JAR, its URL should look like this:
            // jar:file:/path/to/the/jar!/org/apache/wicket/Component.class
            
            // Replace the part after the ! with the manifest path.
            // That way we open the manifest stored in that particular JAR.
            
            if(classRsrc.toString().startsWith("jar:") &&
               classRsrc.toString().indexOf(path) > 0)
            {
                url = classRsrc.toString().replace(path, MANIFEST_PATH);
            }
        }
        try
        {
            return fromUrl(url != null ? new URL(url) : null);
        }
        catch(MalformedURLException ignore)
        {
            return fromUrl(null);
        }
    }