public static URL extractJarFileURL(URL jarUrl) throws MalformedURLException {
  String urlFile=jarUrl.getFile();
  int separatorIndex=urlFile.indexOf(JAR_URL_SEPARATOR);
  if (separatorIndex != -1) {
    String jarFile=urlFile.substring(0,separatorIndex);
    try {
      return new URL(jarFile);
    }
 catch (    MalformedURLException ex) {
      if (!jarFile.startsWith("/")) {
        jarFile="/" + jarFile;
      }
      return new URL(FILE_URL_PREFIX + jarFile);
    }
  }
 else {
    return jarUrl;
  }
}

public static URL extractJarFileURL ( URL jarUrl ) throws MalformedURLException { String urlFile = jarUrl . getFile ( ) ; int separatorIndex = urlFile . indexOf ( JAR_URL_SEPARATOR ) ; if ( separatorIndex != - 1 ) { String jarFile = urlFile . substring ( 0 , separatorIndex ) ; try { return new URL ( jarFile ) ; } catch ( MalformedURLException ex ) { if ( ! jarFile . startsWith ( "/" ) ) { jarFile = "/" + jarFile ; } return new URL ( FILE_URL_PREFIX + jarFile ) ; } } else { return jarUrl ; } }
extract the url for the actual jar file from the given url ( which may point to a resource in a jar file or to a jar file itself ) .
