include external jar when running java -jar

Is there a reason why you are avoiding invoking the main class like java -cp /usr/local/jar/foobar.jar:/some/other/path.jar com.your.main.classname ? This type of invocation allows you to mix absolute paths with relative paths. Put this into a shell script or batch file to avoid having to actually type or remember the full classpath to simplify things.

How to read MANIFEST.MF file from JAR using Bash

$ unzip -q -c myarchive.jar META-INF/MANIFEST.MF -q will suppress verbose output from the unzip program -c will extract to stdout Example: $ unzip -q -c commons-lang-2.4.jar META-INF/MANIFEST.MF Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.0 Created-By: 1.5.0_13-119 (Apple Inc.) Package: org.apache.commons.lang Extension-Name: commons-lang Specification-Version: 2.4 Specification-Vendor: Apache Software Foundation Specification-Title: Commons Lang Implementation-Version: 2.4 Implementation-Vendor: Apache Software … Read more

Use of the MANIFEST.MF file in Java

The content of the Manifest file in a JAR file created with version 1.0 of the Java Development Kit is the following. Manifest-Version: 1.0 All the entries are as name-value pairs. The name of a header is separated from its value by a colon. The default manifest shows that it conforms to version 1.0 of … Read more

Reading my own Jar’s Manifest

You can do one of two things: Call getResources() and iterate through the returned collection of URLs, reading them as manifests until you find yours: Enumeration<URL> resources = getClass().getClassLoader() .getResources(“META-INF/MANIFEST.MF”); while (resources.hasMoreElements()) { try { Manifest manifest = new Manifest(resources.nextElement().openStream()); // check that this is your manifest and do what you need or get the … Read more