From 2ef9e3fe2345c0cecced5fd2bb54683e60f49aec Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Sat, 16 May 2026 23:28:03 +0200 Subject: [PATCH] Add clearer JBang wrapper example --- README.md | 3 ++ examples/jbang-wrap/README.md | 68 ++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2c211f5..5e2fd96 100644 --- a/README.md +++ b/README.md @@ -295,6 +295,9 @@ echo "JPAXAJPAXAJPAXA" >> stubs/stub-linux-arm_32 See the `examples/` directory for sample applications. +- [`examples/jbang-wrap`](./examples/jbang-wrap): package a JBang wrapper and ship a single executable +- [`examples/simple-java`](./examples/simple-java): package a small Java application + ## Limitations - first run pays extraction cost diff --git a/examples/jbang-wrap/README.md b/examples/jbang-wrap/README.md index bec5907..3072e23 100644 --- a/examples/jbang-wrap/README.md +++ b/examples/jbang-wrap/README.md @@ -1,23 +1,57 @@ -# Simple JBang Example +# JBang wrapper example -This example shows how to package jbang wrapper to run -anything jbang is capable of running. +This example shows how to package a JBang wrapper with `jpaxa` so you can ship a single executable that can run a JBang app on the target machine. -## Steps +## What it demonstrates -1. Compile the Java application: - ```bash - javac Hello.java - ``` +- wrapping an app directory that already contains the JBang wrapper scripts +- using `{{jpaxa}}` to locate the extracted wrapper at runtime +- producing a single self-extracting executable instead of asking users to unpack files manually -2. Package it with jpaxa: - ```bash - jpaxa . -- "{{app}}/jbang" "env@jbangdev" - ``` +## Prepare the wrapper -3. Run the packaged executable: - ```bash - ./jbang-wrap additional args - ``` +From this directory, create the JBang wrapper files: -Note: On Windows, use `hello.exe` as the output name. +```bash +jbang wrapper install -d . +``` + +That gives you files such as `jbang`, `jbang.cmd`, and `jbang.ps1` inside this example directory. + +## Build the executable + +### macOS / Linux + +```bash +jpaxa \ + --input . \ + --output jbang-wrap \ + -- "{{jpaxa}}/jbang" "env@jbangdev" +``` + +### Windows + +```bash +jpaxa \ + --input . \ + --output jbang-wrap.exe \ + -- "{{jpaxa}}/jbang.cmd" "env@jbangdev" +``` + +## Run it + +```bash +./jbang-wrap +``` + +You should see the output from `env@jbangdev`, executed through the extracted JBang wrapper bundled in the executable. + +## Why this example matters + +This is one of the nicest `jpaxa` use cases: + +- author a tool with JBang +- bundle the wrapper once +- ship a single file to users + +No installer, no manual unzip step, and no need to explain the internal file layout to the user.