Jens Knipper

JavaScript? No. Java Scripts! - Scripting with Java

Think Java is too verbose for scripting? See how modern features and tools let you write powerful, dependency-managed scripts in a single file.

JavaScript? No. Java Scripts! - Scripting with Java
#1about 2 minutes

Comparing Java with Bash and Python for scripting

Bash syntax is difficult to remember and Python's tooling can be a mess, creating an opening for other scripting languages.

#2about 2 minutes

Re-evaluating Java's suitability for modern scripting tasks

While traditionally seen as verbose, Java's static typing, performance, and massive ecosystem make it a strong contender for scripting.

#3about 4 minutes

Running single-file Java programs without manual compilation

Modern JDKs allow you to execute a .java source file directly with the `java` command, which compiles the code in memory.

#4about 3 minutes

Making Java scripts directly executable using shebangs

Since Java 11, you can add a shebang line to the top of a Java file to make it directly executable from the command line.

#5about 3 minutes

Reducing boilerplate with simplified main methods and I/O

Recent JDK enhancements introduce a simpler `void main()` method and concise `io.println` functions to make scripts less verbose.

#6about 10 minutes

Handling multi-file programs and dependencies natively

The `java` command can run programs spanning multiple source files and include external JARs using the `--classpath` flag, though managing transitive dependencies is difficult.

#7about 5 minutes

Using JBang to simplify dependency management in scripts

JBang eliminates the need for a traditional project setup by managing dependencies, including transitive ones, declared directly in the source file.

#8about 7 minutes

Building interactive CLI applications with JBang and PicoCLI

Use JBang templates with the PicoCLI library to easily create robust command-line applications with arguments, options, and help text.

#9about 5 minutes

Creating terminal user interfaces in Java with Tambui

The Tambui library enables the creation of interactive terminal user interface (TUI) applications in Java, inspired by tools like Rust's `ratatui`.

#10about 5 minutes

Compiling native binaries and installing scripts with JBang

JBang can compile scripts into fast-starting native binaries using GraalVM and install them globally for easy access from anywhere on your system.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles

From learning to earning

Jobs that call for the skills explored in this talk.