private static AppData loadMainClassFromClasspathJar(File jarFile, String[] args) throws Exception {
    List<String> properties = Collections.emptyList();
    String[] mainArgs;

    try (JarInputStream inputStream = new JarInputStream(new FileInputStream(jarFile))) {
      Manifest manifest = inputStream.getManifest();

      String vmOptions = manifest != null ? manifest.getMainAttributes().getValue("VM-Options") : null;
      if (vmOptions != null) {
        properties = splitBySpaces(vmOptions);
      }

      String programParameters = manifest != null ? manifest.getMainAttributes().getValue("Program-Parameters") : null;
      if (programParameters == null) {
        mainArgs = Arrays.copyOfRange(args, 2, args.length);
      }
      else {
        List<String> list = splitBySpaces(programParameters);
        mainArgs = list.toArray(new String[0]);
      }
    }
    finally {
      jarFile.deleteOnExit();
    }

    return new AppData(properties, Class.forName(args[1]), mainArgs);
  }
private static AppData loadMainClassFromClasspathJar(File jarFile, String[] args)