Java Clean Architecture Masterclass

Java Clean Architecture MasterclassNov 20-21

Join

JBang - Unleash the Power of Java 🚀

Table of Contents

Release Downloads Build Status Che Gitpod Chat OpenSSF Scorecard

JBang Logo

Want to learn, explore or use Java instantly without setup?

Do you like Java but use Python, Groovy, Kotlin or similar languages for scripts, experimentation and exploration?

Ever wanted to just be able to run Java from anywhere without any or very minimal setup?

Then JBang is for you! 🎉

Quick Start

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

# Create and run your first script
jbang init --template=cli hello.java
jbang hello.java Max!

4AiobRxUwPUPztCtrDYcmoKjs

What is JBang?

JBang makes it easy to write and run Java scripts without traditional project setup. It handles:

  • Zero setup - Run .java files directly

  • Dependency management - Declare with //DEPS, auto-resolve from Maven

  • Multiple languages - Java, Kotlin, Groovy, JShell, Markdown

  • IDE integration - Full IDE support with jbang edit

  • Native compilation - Generate native binaries with GraalVM

  • Script sharing - Via GitHub, catalogs, and aliases

Key Features

Instant Java scripting - No build files, no project setup ✅ Dependency management - Maven-style deps with //DEPSMultiple file types - .java, .jsh, .kt, .groovy, .mdIDE support - Full IntelliSense with jbang editCross-platform - Windows, macOS, Linux, AIX ✅ Native images - GraalVM native-image support ✅ Easy sharing - GitHub URLs, catalogs, aliases ✅ Template system - Quick start with jbang init

Installation

Quick Install (recommended):

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

Package managers: - SDKMan: sdk install jbang - Homebrew: brew install jbangdev/tap/jbang - Chocolatey: choco install jbang - Scoop: scoop install jbang

See installation docs for more options.

Examples

Hello World

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

class hello {
    public static void main(String[] args) {
        System.out.println("Hello " + (args.length > 0 ? args[0] : "World"));
    }
}

CLI App with Dependencies

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

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

@Command(name = "hello", mixinStandardHelpOptions = true)
class hello implements Runnable {
    @Parameters(index = "0", description = "The greeting to print")
    private String greeting;

    public static void main(String[] args) {
        new CommandLine(new hello()).execute(args);
    }

    public void run() {
        System.out.println("Hello " + greeting);
    }
}

Web Server

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS com.sun.net.httpserver:http:20070405

import com.sun.net.httpserver.*;
import java.io.IOException;
import java.net.InetSocketAddress;

class WebServer {
    public static void main(String[] args) throws IOException {
        HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
        server.createContext("/", exchange -> {
            String response = "Hello from JBang!";
            exchange.sendResponseHeaders(200, response.length());
            exchange.getResponseBody().write(response.getBytes());
            exchange.close();
        });
        server.start();
        System.out.println("Server started at http://localhost:8000");
    }
}

Common Commands

# Create new script from template
jbang init --template=cli myapp.java

# Run script with dependencies
jbang myapp.java

# Edit with full IDE support
jbang edit myapp.java

# Run remote script
jbang https://github.com/user/repo/blob/main/script.java

# Create alias for easy access
jbang alias add --name myapp myapp.java

# Export to traditional project
jbang export maven myapp.java

# Create native binary
jbang --native myapp.java

# Install as system command
jbang app install myapp.java

AppStore

Beyond scripting, JBang can launch any Java application packaged as a JAR. Check out the AppStore for examples and community-contributed scripts.

Documentation

📖 Full documentation: https://jbang.dev/documentation

Quick links:

Community

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Thanks

JBang was heavily inspired by kscript by Holger Brand.

License

JBang is released under the MIT License.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.