Runtime Package
The org.apache.juneau.commons.runtime package provides lean accessors for two common runtime inputs: command-line arguments and JAR manifest files.
Command-Line Arguments
Args
A lean parser for command-line arguments passed to a main(String[]) method. It supports positional arguments, -key value, --key, --key=value, and -Dkey=value grammars (all enabled by default), returning values via an Optional-based API.
public static void main(String[] argv) {
Args args = new Args(argv);
Optional<String> config = args.get("config"); // --config value
List<String> files = args.positional(); // bare arguments
}
Grammar options can be toggled via Args.create().
Manifest Files
ManifestFile
A lean accessor for the contents of a JAR manifest. Wraps a java.util.jar.Manifest and exposes main-attribute and per-section entries via an Optional-returning API — constructable from a Class, File, Path, InputStream, Reader, or Manifest.
ManifestFile mf = new ManifestFile(MyClass.class);
Optional<String> version = mf.get("Implementation-Version");
See also
- SVL Variables: the
$Aand$MFvariables read the same arguments and manifest entries. - Simple Variable Language