JAR Tool

Elide ships a native-compiled jar tool — the same implementation as the JDK's jar, but compiled ahead-of-time with GraalVM. This eliminates JVM startup overhead entirely, making JAR assembly near-instant even for scripting and CI pipelines where the JVM cold-start cost would otherwise dominate. It is exposed in two ways:

  1. Drop-in replacementelide jar -- [OPTION...] passes arguments directly to the embedded jar tool with no JVM startup cost.
  2. Build system integrationelide build assembles JARs automatically based on artifact declarations in elide.pkl.

A third shortcut — elide javac --jar — compiles Java source and packages the result into a JAR in one step.

---

Drop-in Usage

elide jar exposes the embedded sun.tools.jar.JarToolProvider implementation — natively compiled, so it starts instantly without a JVM. All arguments after -- are forwarded to the underlying tool verbatim, giving you full compatibility with existing jar invocations at a fraction of the startup time.
elide jar -- [OPTION...] [ [--release VERSION] [-C dir] files] ...
Note

There are no Elide-specific options before -- at this time. The -- separator is still required.

Path format

File and directory arguments must be specified as paths, not bare filenames. Use ./Foo.class, ./classes.jar, or absolute paths like /path/to/file. Bare names without a path prefix (e.g. Foo.class) will produce an error.

Main Operations

FlagShortDescription
—create-cCreate an archive
—extract-xExtract files from an archive
—list-tList the table of contents
—update-uUpdate an existing archive
—describe-module-dPrint the module descriptor or automatic module name
—validateValidate a multi-release JAR for API consistency across versions

Common Modifiers

FlagDescription
-f FILE, —file=FILEArchive file name (omit to use stdin/stdout)
-C DIR .Change to the given directory and include all files from it
-m FILE, —manifest=FILEInclude manifest from the given file
-M, —no-manifestDo not create a manifest
-e CLASS, —main-class=CLASSApplication entry point for executable JARs
—release VERSIONPlace following files under META-INF/versions/VERSION/
—module-version=VERSIONSet the module version
—module-pathLocation of module dependencies for hash computation
—hash-modules=PATTERNCompute and record hashes of matched modules
-0, —no-compressStore only; no ZIP compression
—date=TIMESTAMPISO-8601 timestamp for entry metadata
-k, —keep-old-filesDo not overwrite existing files during extraction
—dirDirectory to extract into
-v, —verboseVerbose output

Examples

Create an archive from two class files:

bash
 elide jar -- --create --file ./classes.jar ./Foo.class ./Bar.class

Create an archive from a directory with a custom manifest:

bash
 elide jar -- --create --file ./classes.jar --manifest ./mymanifest -C ./foo/ .

Create an executable modular JAR:

bash
 elide jar -- --create --file ./app.jar --main-class com.example.Main --module-version 1.0 \
 -C ./build/classes .

Update a non-modular JAR to a modular JAR:

bash
 elide jar -- --update --file ./app.jar --main-class com.example.Main --module-version 1.0 \
 -C ./build/classes module-info.class

Create a multi-release JAR:

bash
 elide jar -- --create --file ./mr.jar -C ./foo classes --release 9 -C ./foo9 classes

List the contents of a JAR:

bash
 elide jar -- --list --file ./app.jar

Extract a JAR into a directory:

bash
 elide jar -- --extract --file ./app.jar --dir ./extracted

---

Build System Integration

When using elide build with an elide.pkl project file, JAR packaging is handled automatically by the build task graph. Three artifact types are supported: classes JARs, sources JARs, and Javadoc JARs.

Declaring Artifacts

Artifacts are declared under the artifacts mapping in elide.pkl. Import elide:Jvm.pkl to access the JAR types:

pkl
amends "elide:project.pkl"
import "elide:Jvm.pkl" as Jvm
import "elide:Sources.pkl" as Src

name = "my-library"

sources {
  ["main"] = new Src.SourceSetSpec {
    paths {
      "src/main/java<<>>*.java"
    }
  }
}

artifacts {
  ["app"] = new Jvm.Jar {
    name = "my-library"
    sources { "main" }
  }
  ["sources"] = new Jvm.SourceJar {
    from { "main" }
  }
  ["docs"] = new Jvm.JavadocJar {
    from { "main" }
  }
}

Classes JAR (Jvm.Jar)

Packages compiled .class files from upstream compilation tasks, along with any declared resources, into a single JAR. The manifest is generated automatically and includes Manifest-Version, Created-By, Implementation-Title, Implementation-Version, and Main-Class (if an entrypoint is configured).

Output path: artifacts/jar/{name}/{name}.jar Options:
FieldTypeDefaultDescription
nameString?artifact keyFilename for the output JAR (without .jar)
sourcesListing<String>{ "main" }Source sets whose compiled classes to include
resourcesMapping<path, path>emptyResource files to embed in the JAR
manifestMapping<String, String>emptyAdditional manifest key-value entries
manifestFileString?nonePath to a manifest file to use
excludesListing<String>emptyGlob patterns for files to exclude
options.compressBooleantrueWhether to apply ZIP compression
options.defaultManifestPropertiesBooleantrueWhether to add standard manifest entries
options.entrypointString?noneMain class for an executable JAR
Example — executable JAR:
pkl
artifacts {
  ["app"] = new Jvm.Jar {
    name = "my-app"
    sources { "main" }
    options {
      entrypoint = "com.example.Main"
    }
  }
}
Example — with custom manifest entries:
pkl
artifacts {
  ["app"] = new Jvm.Jar {
    name = "my-library"
    sources { "main" }
    manifest {
      ["Implementation-Vendor"] = "Acme Corp"
      ["Bundle-SymbolicName"] = "com.example.my-library"
    }
  }
}
Example — with embedded resources:
pkl
artifacts {
  ["app"] = new Jvm.Jar {
    name = "my-app"
    sources { "main" }
    resources {
      ["/config/defaults.properties"] = "src/main/resources/defaults.properties"
    }
  }
}

Sources JAR (Jvm.SourceJar)

Packages source files from the declared source sets into a JAR with a -sources classifier. Commonly used for IDE support and Maven publishing.

Output path: artifacts/jar/{name}/{name}-sources.jar
FieldTypeDefaultDescription
fromListing<String>emptySource sets to package
classifierString?"sources"Custom classifier for the output filename
excludesListing<String>emptyGlob patterns to exclude
includesListing<String>emptyGlob patterns to include
Example:
pkl
artifacts {
  ["sources"] = new Jvm.SourceJar {
    from { "main" }
    excludes { "**/*.generated.java" }
  }
}

Javadoc JAR (Jvm.JavadocJar)

Runs the javadoc tool over Java source files and packages the resulting HTML documentation into a JAR with a -javadoc classifier.

Output path: artifacts/jar/{name}/{name}-javadoc.jar
FieldTypeDefaultDescription
fromListing<String>emptySource sets containing Java files to document
linksListing<String>emptyExternal documentation URLs to link
excludesListing<String>emptyPackage patterns to exclude
windowTitleString?"{name} API"Browser window title
docTitleString?"{name} API Documentation"Documentation page title
groupsMapping<String, Listing<String>>emptyPackage groupings (title -> packages)
Example:
pkl
artifacts {
  ["docs"] = new Jvm.JavadocJar {
    from { "main" }
    windowTitle = "My Library API"
    links {
      "https:<<>>
    }
    excludes { "com.example.internal" }
  }
}

---

Compile and Package in One Step

elide javac accepts a --jar flag that compiles Java sources and immediately packages the compiled classes into a JAR, without needing a separate elide jar invocation.
bash
 elide javac --jar < output.jar> [--manifest < manifest-file>] -- <source files...>

The compilation output goes to target/ in the current working directory. The JAR is then assembled from that directory.

Example — compile and package:
bash
 elide javac --jar ./target/app.jar -- ./src/Main.java ./src/Util.java
Example — with a custom manifest:
bash
 elide javac --jar ./target/app.jar --manifest ./src/MANIFEST.MF -- ./src/Main.java
Note

--jar and --manifest are Elide flags and must appear before the -- separator. Source files go after --.