Show Menu

Unleash the power of Java

Simple JBang

///usr/bin/env jbang "$0" "$@" ; exit $? 

class Hello { 
    public static void main(String[] args) {
          System.out.println("Hello World!");

Run JBang script

$ jbang
$ jbang --debug
$ chmod u+x 
$ ./


$ jbang template list
$ jbang init --template=cli


$ jbang edit hellow­orl­
$ jbang edit --open­=code hellow­orl­
$ jbang edit --open­=idea hellow­orl­

Assign Java version

//JAVA 8
Assigned version in Script
//JAVA 11+
Java 11 or higher
jbang --java 8
Assigned version from CLI

java and javac Options

//JAVAC_OPTIONS --enable-preview --release 17
//JAVA_OPTIONS --enable-preview 
//JAVA_OPTIONS -Dserver.port=8081 -D

Multiple Java source files

//SOURCES impl/

Multi resource files - proper­tie­s/xml etc

//FILES META-INF/resources/index.html=index.html
//FILES META-INF/resources/jquery.js=

Resource import format: //FILES <mountpoint>[=<sourcefile>]

Polyglot - Kotlin

///usr/bin/env jbang "$0" "$@" ; exit $? 

//KOTLIN 1.6.10
//DEPS org.jetbrains.kotlin: kotlin-stdlib-jdk8:1.6.10

public fun main() {
    println("Hello World");

Polyglot - Groovy

///usr/bin/env jbang "$0" "$@" ; exit $? 

//GROOVY 4.0.0

println("Hello World");

Polyglot - JShell

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.github.javafaker:javafaker:1.0.2

import com.github.javafaker.Faker;

Faker faker = new Faker();
$ jbang demo.jsh
$ jbang --inte­ractive demo.jsh

JBang native



//DEPS org.projectlombok:lombok:1.18.22
//DEPS org.apache.commons:commons-lang3:3.12.0

Managed depend­encies by BOM - Spring Boot

//DEPS org.springframework.boot:spring-boot-dependencies:2.6.3@pom
//DEPS org.springframework.boot:spring-boot-starter

Managed depend­encies by BOM - Quarkus

//DEPS io.quarkus:quarkus-bom:2.7.1.Final@pom
//DEPS io.quarkus:quarkus-resteasy


//REPOS mavencentral,spring-release=
//REPOS mavencentral,spring-milestone=

Well-known repositories:

* mavencentral -
* google -
* jitpack -


$ jbang alias add --name hello
$ jbang hello 
$ jbang alias list
$ jbang alias list --show-origin

Catalogs - jbang-­cat­alo­g.json

  "aliases": {
    "hello": {
      "script-ref": "",
      "description": "Script that says hello back for each argument"

Catalogs - local jbang-­cat­alo­gs.json

1. jbang-­cat­alo­g.json in current directory
2. jbang-­cat­alo­g.json in parent directory util the root diretory
3. $HOME/.jb­ang­/jb­ang­-ca­tal­og.json

Catalogs - implicit catalog from GitHub

jbang hello@acme
hello alias in acme/j­ban­g-c­ata­log­/jb­ang­-ca­tal­og.json
jbang hello@­acm­e/m­yca­talog
hello alias in acme/m­yca­tal­og/­jba­ng-­cat­alo­g.json
jbang hello@­acm­e/m­yca­tal­og/dev
hello alias in acme/m­yca­tal­og/­jba­ng-­cat­alo­g.json in dev branch
jbang hello@­acm­e~e­xpe­rim­ental
hello alias in acme/j­ban­g-c­ata­log­/ex­per­ime­nta­l/j­ban­g-c­ata­log.json

Catalogs - management

$ jbang catalog add --name acme acme
$ jbang catalog add --name mycatalog acme/mycatalog
$ jbang catalog list


jbang --fresh
Use none-c­ached resources
jbang info tools
Prints a json descri­ption of JBang script

Apps - setup jbang to put scripts into your PATH

$ jbang app install <scriptRef> 
$ $ jbang app install --name app1 <scriptRef> 
$ jbang app list
$ jbang app uninstall <name>

///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS info.picocli:picocli:4.6.3
//FILES resources


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by linux_china

          Justfile Cheat Sheet
          httpx Cheat Sheet