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! π
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
β
Instant Java scripting - No build files, no project setup
β
Dependency management - Maven-style deps with //DEPS
β
Multiple file types - .java
, .jsh
, .kt
, .groovy
, .md
β
IDE support - Full IntelliSense with jbang edit
β
Cross-platform - Windows, macOS, Linux, AIX
β
Native images - GraalVM native-image support
β
Easy sharing - GitHub URLs, catalogs, aliases
β
Template system - Quick start with jbang init
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.
///usr/bin/env jbang "$0" "$@" ; exit $?
class hello {
public static void main(String[] args) {
System.out.println("Hello " + (args.length > 0 ? args[0] : "World"));
}
}
///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);
}
}
///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");
}
}
# 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
Beyond scripting, JBang can launch any Java application packaged as a JAR. Check out the AppStore for examples and community-contributed scripts.
π Full documentation: https://jbang.dev/documentation
Quick links:
-
π Quick Start Guide
-
π¦ Installation
-
π Basic Usage
-
π§ Dependencies
-
π― Templates
-
π οΈ IDE Integration
-
β FAQ
-
π¬ Chat: Zulip Community
-
π Issues: GitHub Issues
-
ποΈ App Store: JBang App Store
-
π Examples: jbang-examples
We welcome contributions! Please see our Contributing Guide for details.
JBang was heavily inspired by kscript by Holger Brand.
JBang is released under the MIT License.