code: protected static String findJarName( String fileName, String[] classpath )
      {
          if ( classpath == null )
          {
              return new File( fileName ).getName();
          }
          fileName = fileName.replace( File.separatorChar, '/' );
          SortedMap<String, String> matches = new TreeMap<String, String>( new Comparator<String>()
          {
              // longest match comes first
              public int compare( String o1, String o2 )
              {
                  if ( ( o1 != null ) && ( o2 != null ) )
                  {
                      return o2.length() - o1.length();
                  }
                  return 0;
              }
          } );
  
          for ( String aClasspath : classpath )
          {
              if ( fileName.endsWith( aClasspath ) )
              {
                  matches.put( aClasspath, aClasspath );
              }
              else
              {
                  int slash = aClasspath.indexOf( "/" );
                  String candidate = aClasspath;
                  while ( slash > -1 )
                  {
                      candidate = candidate.substring( slash + 1 );
                      if ( fileName.endsWith( candidate ) )
                      {
                          matches.put( candidate, aClasspath );
                          break;
                      }
                      slash = candidate.indexOf( "/" );
                  }
              }
          }
  
          return matches.size() == 0 ? null : matches.get( matches.firstKey() );
      }
docs: try to guess the name of the given file.
  <p/>
  <p>If this jar has a classpath attribute in its manifest, we
  can assume that it will only require an index of jars listed
  there.  try to find which classpath entry is most likely the
  one the given file name points to.</p>
  <p/>
  <p>In the absence of a classpath attribute, assume the other
  files will be placed inside the same directory as this jar and
  use their basename.</p>
  <p/>
  <p>if there is a classpath and the given file doesn't match any
  of its entries, return null.</p>
  
  @param fileName  .
  @param classpath .
  @return The guessed name