8000 GitHub - jbangdev/jbang: Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
[go: up one dir, main page]

Skip to content
/ jbang Public

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.

License

Notifications You must be signed in to change notification settings

jbangdev/jbang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

JBang - Unleash the Power of Java πŸš€

Release Downloads Build Status Che Gitpod Chat SourceSpy 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 //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

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.

About

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published
0