Installation

To use jbang Java 8 is the minimum required version, however Java 17 or higher is recommended. To use jbang Java 8 is the minimum required version, however Java 17 or higher is recommended.

Note: jbang will download and install java from Eclipse Temurin if no java is available. Note: jbang will download and install java from Eclipse Temurin if no java is available.

There are multiple ways to install jbang. See below for all available options.

Once you have jbang installed, it is recommended you run jbang app setup. This script will make the following changes to your system:

  1. Modify PATH environment variable to include jbang app scripts

  2. For supported shells, add j! as an alias for jbang. Try running j! version to verify.

By default jbang uses ~/.jbang for configurations and build cache. This can be changed using the environment variable JBANG_DIR.

Installation Methods

Universal (All Platforms)

Using JBang (curl/bash)

Linux/OSX/Windows/AIX Bash:

curl -Ls https://sh.jbang.dev | bash -s - app setup

Windows Powershell:

iex "& { $(iwr -useb https://ps.jbang.dev) } app setup"

Zero Install (curl/bash and Powershell)

Linux/OSX/Windows/AIX Bash:

curl -Ls https://sh.jbang.dev | bash -s - <arguments>

For example curl -Ls https://sh.jbang.dev | bash -s - properties@jbangdev

Windows Powershell:

iex "& { $(iwr -useb https://ps.jbang.dev) } <arguments>"

For example iex "& { $(iwr -useb https://ps.jbang.dev) } properties@jbangdev"

Manual install

Unzip the latest binary release, add the jbang-<version>/bin folder to your $PATH and you are set.

Wrapper install

If you would like to have jbang available in a local directory and committed into a source code repository (akin to Maven and Gradle wrappers) you can use the jbang wrapper command.

If you have jbang already installed you call jbang wrapper install in a folder to install a local jbang that will run out of that directory using ./jbang.

The ./.jbang directory which jbang wrapper install creates is just a cache which you typically would not commit to a source code repository, so you can e.g. echo .jbang/ >>.gitignore.

Linux & macOS

SDKMan

Although if you want to have easy updates or install multiple JBang versions we recommend sdkman to install both java and jbang on Linux and OSX.

curl -s "https://get.sdkman.io" | bash (1)
source ~/.bash_profile (2)

sdk install java (3)

Once Java is installed and ready, you install jbang with

sdk install jbang

To test your installation run:

jbang --help

This should print out usage information.

To update run:

sdk upgrade jbang

asdf

You can install JBang using the asdf version manager:

asdf plugin-add jbang
asdf install jbang latest

Homebrew (macOS)

On OSX you can install 'java' and jbang with Homebrew using custom taps.

To install Java 17:

brew install temurin@17 --cask

Once Java is installed you can use brew with jbangdev/tap to get jbang:

brew install jbangdev/tap/jbang

To upgrade to latest version:

brew upgrade jbangdev/tap/jbang

(Experimental) Linux packages

These builds are not fully automated yet thus might be slightly behind.

You can install rpm packages from Fedora Copr by doing the following:

dnf copr enable @jbangdev/jbang
dnf install jbang

The COPR currently includes builds from various versions of CentOS, Fedora, Mageia and OpenSuse.

Windows

Chocolatey

On Windows you can install both java and jbang with Chocolatey.

From a command prompt with enough rights to install with choco:

choco install jdk11

Once Java in installed run:

choco install jbang

To upgrade to latest version:

choco upgrade jbang

The latest package will be published to jbang choco package page, it might be a bit delayed as the review is still manual. In case the default version is not the latest you can see the version list and install specific version using:

choco install jbang --version=<version number>

Scoop

On Windows you can also install jbang with Scoop.

scoop bucket add jbangdev https://github.com/jbangdev/scoop-bucket
scoop install jbang

To upgrade to latest version:

scoop update jbang

Homebrew

On OSX you can install 'java' and jbang with Homebrew using custom taps.

To install Java 11:

brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk11 --cask

Once Java is installed you can use brew with jbangdev/tap to get jbang:

brew install jbangdev/tap/jbang

To upgrade to latest version:

brew upgrade jbangdev/tap/jbang

(Experimental) Linux packages

These builds are not fully automated yet thus might be slightly behind.

You can install rpm packages from Fedora Copr by doing the following:

dnf copr enable @jbangdev/jbang
dnf install jbang

The COPR currently includes builds from various versions of CentOS, Fedora, Mageia and OpenSuse.

Docker / GitHub Action

You can run jbang via Docker:

docker run -v `pwd`:/ws --workdir=/ws -ti jbangdev/jbang-action helloworld.java

or if you prefer using Quay.io:

docker run -v `pwd`:/ws --workdir=/ws -ti quay.io/jbangdev/jbang-action helloworld.java

The same container images can be used with GitHub Actions, see jbang-action for details.

Remember to remove -ti from the commands above when using on a GitHub Actions flow.

GitHub Actions

You can use JBang in your GitHub Actions workflows:

- name: Setup JBang
  uses: jbangdev/setup-jbang@main

- name: Run script
  run: |
    jbang properties@jbangdev

Build Tools

Maven Plugin

The JBang Maven plugin allows JBang scripts to be executed during a Maven build.

Example in your pom.xml:

      <plugin>
        <groupId>dev.jbang</groupId>
        <artifactId>jbang-maven-plugin</artifactId>
        <version>0.0.8</version>
        <executions>
          <execution>
            <id>run</id>
            <phase>process-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
                <script>hello.java</script>
            </configuration>
          </execution>
        </executions>
      </plugin>

The plugin documentation and more examples are available here: https://github.com/jbangdev/jbang-maven-plugin

Gradle Plugin

The JBang Gradle plugin allows JBang scripts to be executed during a Gradle build.

In your build.gradle file, add:

plugins {
    id 'dev.jbang' version '0.2.0'
}

That will allow you to execute JBang scripts with:

$ gradle jbang --jbang-script hello.jsh --jbang-args="Hello world"

The plugin documentation and more examples are available here: https://github.com/jbangdev/jbang-gradle-plugin

Programming Language Integrations

JavaScript/Node.js (npx/npm)

You can use JBang via Node.js using npx or by installing the npm package:

npx @jbangdev/jbang app setup

Or add to your package.json:

{
  "devDependencies": {
    "@jbangdev/jbang": "^0.1.4"
  }
}

And use in your scripts:

// test.js:
#! /usr/bin/env node
const jbang = require('@jbangdev/jbang');
jbang.exec('properties@jbangdev');

Python (pipx/uvx/pip)

You can use JBang from Python environments:

pipx jbang app setup
uvx jbang app setup

Or in a Jupyter notebook:

!pip install jbang
import jbang
jbang.exec('properties@jbangdev')