Recent Posts
Archives

Posts Tagged ‘Worldline’

PostHeaderIcon [DevoxxUK2025] Scripting on the JVM with JBang: Simplifying Java Development

Yassine Benabbas, a data engineer at Worldline and a passionate educator, delivered an engaging session at DevoxxUK2025 on JBang, a tool that simplifies Java, Kotlin, and Groovy scripting. Through live demos using Jupyter notebooks, Yassine showcased how JBang streamlines small-scale development, making it as intuitive as Python. His talk covered JBang’s setup, core features, and advanced capabilities like remote script execution and catalog integration, emphasizing its value for prototyping, teaching, and sharing code. Yassine’s enthusiasm for JBang highlighted its potential to make Java development accessible and enjoyable for diverse audiences.

JBang’s Core Features: Scripting Made Simple

Yassine introduced JBang as a command-line tool that transforms Java development by enabling single-file scripts, akin to shell or Python scripts. Using a shebang line (#!/usr/bin/env jbang), developers can run Java files directly from the terminal, as demonstrated with a “Hello World” example. JBang’s init command generates a basic Java file, and its export capabilities produce JARs, fat JARs, or native images effortlessly. For prototyping, JBang supports converting scripts into Maven or Gradle projects, maintaining simplicity while scaling to full-fledged applications. This flexibility makes it ideal for educators, demo developers, and hobbyists who need quick, lightweight solutions without complex build tools.

Templates and Multi-Language Support

JBang’s template system was a highlight, allowing developers to bootstrap projects with pre-configured code. Yassine showcased templates for command-line apps (using Picocli) and Quarkus REST APIs, demonstrating how JBang creates single-file REST APIs in Java, rivaling other languages’ simplicity. Beyond Java, JBang supports Kotlin and Groovy, and even executes Java code blocks within Markdown files. A demo showed initializing a Kotlin script with a shebang line, running seamlessly via JBang. These features empower developers to reuse code efficiently, making JBang a versatile tool for rapid development across JVM languages.

Remote Execution and Catalog Integration

Yassine explored JBang’s ability to run remote scripts by referencing URLs, such as a GitHub-hosted Java file, with a caching mechanism for efficiency. He introduced JBang catalogs, JSON files hosted on platforms like GitHub, which simplify referencing scripts and templates with short aliases (e.g., @yassine/pal-cli for a palindrome checker). The JBang app store, a community-driven UI, allows browsing catalogs, enhancing script discoverability. Yassine also demonstrated a JavaFX template for creating presentations, showcasing how JBang fetches dependencies and runs complex applications, further broadening its applicability for creative and educational use cases.

Links: