Getting Started with Java

Max Rydahl Andersen

What is hard about getting started with Java ?


reddit comparehelloworldpython


reddit installingjava


reddit runningthedamnthing

Getting Started with Java

The JBang Way


curl -Ls | bash -s - app setup
  • Downloads and configure JBang

  • If no Java found, downloads Java 11


$ jbang -c 'println("Hello World")'
Hello World
$ jbang -c 'println("Hello "  + args[0])' Universe
Hello Universe
  • -c evaluates code via JShell

  • Handles user arguments

  • No files to create

  • No public static class main

$ jbang -i
|  Welcome to JShell -- Version 11.0.15
|  For an introduction type: /help intro

jshell> println("Hello!")

Any Java

$ jbang --java 17 -i
WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.foreign
|  Welcome to JShell -- Version 17
|  For an introduction type: /help intro



$ jbang init
[jbang] File initialized. You can now run it with
'jbang' or edit it using
'jbang edit --open=[editor]' where [editor]
is your editor or IDE, e.g. 'eclipse'
$ jbang
[jbang] Building jar...
Hello World
$ ./hello.Java
Hello World

Init w/Templates

$ jbang init -t cli
[jbang] File initialized. You can now run it with
'jbang' or edit it using
'jbang edit --open=[editor]' where [editor]
is your editor or IDE, e.g. 'eclipse'

 ///usr/bin/env jbang "$0" "$@" ; exit $?
 //DEPS info.picocli:picocli:4.5.0

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Parameters;

import java.util.concurrent.Callable;

@Command(name = "app", mixinStandardHelpOptions = true, version = "app 0.1",
        description = "app made with jbang")
class app implements Callable<Integer> {

    @Parameters(index = "0", description = "The greeting to print", defaultValue = "World!")
    private String greeting;

    public static void main(String... args) {
        int exitCode = new CommandLine(new app()).execute(args);

    public Integer call() throws Exception { // your business logic goes here...
        System.out.println("Hello " + greeting);
        return 0;

Run with Dependencies

$ ./
[jbang] Resolving dependencies...
[jbang] info.picocli:picocli:jar:4.5.0
[jbang] Dependencies resolved
[jbang] Building jar...
Hello World

Cached Run

$ ./ --help
Usage: app [-hV] <greeting>
app made with jbang
      <greeting>   The greeting to print
  -h, --help       Show this help message and exit.
  -V, --version    Print version information and exit.


The JBang Way

The Simplest Way

jbang edit
[jbang] You requested to open default editor but no default
editor configured.

jbang can download and configure a visual studio code (VSCodium)
with Java support to use

Do you want to

(1) Download and run VSCodium
(2) Use 'code'
(3) Use 'eclipse'
(4) Use 'idea'
(0) Cancel


Direct IDE Support

IntelliJ intellij

Eclipse and Visual Studio Code In progress


The JBang Way

$ jbang --debug
Listening for transport dt_socket at address: 4004

What just happened?

The JBang Way

In 5 min or less…​

We started creating, then edited, ran and debugged Java

  • Without java or javac

  • Witout mvn or gradle

  • No vscode, eclipse, intellij Install

  • Just jbang


The JBang Way


One liner scripts

$ cat 5letterwords.txt | jbang -c \

Microservices w/Quarkus

$ jbang init -t qrest
$ ./
[jbang] Resolving dependencies...
[jbang] Artifacts used for dependency management:
[jbang] io.quarkus:quarkus-resteasy
[jbang] Dependencies resolved
[jbang] Building jar...
[jbang] Post build with io.quarkus.launcher.JBangIntegration
May 04, 2022 9:30:43 PM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.2.0.Final
May 04, 2022 9:30:44 PM io.quarkus.deployment.QuarkusAugmentor run
INFO: Quarkus augmentation completed in 999ms
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-05-04 21:30:45,453 INFO  [io.quarkus] (main) Quarkus 2.8.0.Final on JVM started in 0.839s. Listening on:
2022-05-04 21:30:45,488 INFO  [io.quarkus] (main) Profile prod activated.
2022-05-04 21:30:45,488 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-bom:${quarkus.version:1.11.0.Final}@pom
//DEPS io.quarkus:quarkus-resteasy
//JAVAC_OPTIONS -parameters
//FILES resources/index.html=index.html
//SOURCES **.java

import io.quarkus.runtime.Quarkus;
import javax.enterprise.context.ApplicationScoped;

public class myservice {
    public String sayHello() {
        return "Hello from Quarkus with";

Run All The Things

$ jbang -c "Hello"
$ jbang
$ jbang demo.jsh
$ jbang app.jar
$ jbang org.jreleaser:jreleaser:1.0.0
$ jbang
$ jbang

Sharing is Caring

  • jbang-catalog repository or jbang-catalog.json

  • Run aliases: jbang env@jbangdev, jbang minecraft-server@microsoft

  • Init templates: jbang init -t githubapp@quarkusio

  • Browse on

JBang AppStore

faker.jsh Example

//DEPS com.github.javafaker:javafaker:1.0.2

import com.github.javafaker.Faker;

Faker faker = new Faker();
$ jbang -s faker@jbangdev -c \
  'Stream.generate(>s.contains("Angie")).forEach(s -> println("Awesome " + s))'

Install All The Things

$ jbang app install -n myapp https://.../a.jar
$ jbang app install quarkus@quarkusio
$ quarkus

Quarkus CLI version 2.8.2.Final

Create Quarkus projects with Maven, Gradle, or JBang.
Manage extensions and source registries.

Create: quarkus create
Iterate: quarkus dev
Build and test: quarkus build

Find more information at
If you have questions, check

Usage: quarkus [-ehv] [--verbose] [-D=<String=String>]... [COMMAND]


  • JBang is the best way to Get started with Java

  • JBang let you write anything; from one-liners…​

  • …​to full-fledged Java microservices

  • JBang lets you run and install Java apps

  • JBang has an appstore

The End …​works with Java, Kotlin and Groovy too!

Slides: GitHub
Built with JBang, AsciiDoctor and reveal.js
Images are various Mandalorian fan-art.