public static Class loadMainClass(String jarFileName) throws Exception {
    Class clss = null;
    try {
      JarFile jarFile = new JarFile(jarFileName);
      Enumeration enums = jarFile.entries();
      while (enums.hasMoreElements()) {
        JarEntry entry = (JarEntry)enums.nextElement();
        if (entry.isDirectory()) continue;
        String fileClassName = entry.getName();
        if (fileClassName.compareToIgnoreCase("META-INF/MANIFEST.MF") != 0) {
          clss = tryLoadMainClass(jarFileName, fileClassName);
          if (clss != null) break; // load main-class
        }
      }
    }
    catch (IOException exc) {
      throw new Exception("loadMainClass: " + exc.getMessage());
    }
    return clss;
  }