Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
68 changes: 51 additions & 17 deletions examples/jbang-wrap/README.md
Original file line number Diff line number Diff line change
@@ -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
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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.
Loading