private static String extractImplementationVersionFromJar(final Path jarPath) throws IOException {
        final String implementationVersion;
        try (final JarFile jarFile = new JarFile(jarPath.toFile())) {
            final Manifest manifest = jarFile.getManifest();

            final String manifestContents;
            try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
                manifest.write(outputStream);
                manifestContents = outputStream.toString();
            }

            final Attributes mainAttributes = manifest.getMainAttributes();
            implementationVersion = mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
        } catch (final IOException ex) {
            throw new IOException("Downloaded an invalid JAR file: No Implementation-Version in MANIFEST", ex);
        }

        if (implementationVersion == null) {
            throw new IOException("Downloaded an invalid JAR file: No Implementation-Version in MANIFEST");
        }
        return implementationVersion;

        // NOTE: Checking embulk/version.rb is no longer needed.
        // "Implementation-Version" has been included in MANIFEST of all-in-one Embulk JARs since v0.4.0.
    }
Runs the selfupdate subcommand of Embulk.

<p>It uses {@link java.net.HttpURLConnection} so that CLI classes do not need additional dependedcies.

<p>TODO: Support HTTP(S) proxy. The original Ruby version did not support as well, though.
embulk-core/src/main/java/org/embulk/cli/SelfUpdate.java