Skip to main content

What's New in JLine 4

JLine 4 is a major release that modernizes the library with new terminal providers, a powerful shell module, improved Unicode handling, and terminal graphics support. This page summarizes the key changes from JLine 3.x.

Requirements​

JLine 3.xJLine 4.x
Minimum JavaJava 8Java 11
Build JDKJava 8Java 22 (for FFM provider)
Maven3.x3.9+
JDK11 Classifier

If you're using Java 11-21 and encounter class file version errors, use the jdk11 classifier to exclude the FFM provider (compiled with Java 22). See Terminal Providers for details.

New Modules​

Shell Module (jline-shell)​

A modern, clean API for building interactive command-line applications, replacing the old Console command infrastructure.

  • Fluent builder API via Shell.builder()
  • Pipeline execution with operators: |, &&, ||, ;, >, >>, <, &
  • Alias system with parameter substitution ($1, $@)
  • Job control — background execution, jobs/fg/bg commands
  • Variable expansion — $VAR, ${VAR:-default}, ~ home expansion
  • Script execution — source / . commands with line continuation
  • Subcommands — automatic routing and tab completion
  • Signal handling — Ctrl-C interrupts the command, not the shell
  • Syntax highlighting — known commands bold, unknown commands red, operators cyan
  • Built-in commands — history, help, setopt/unsetopt/setvar

See Shell: Getting Started and Shell: Features.

Prompt Module (jline-prompt)​

A modern replacement for the Console UI module, built natively on JLine.

  • 11+ prompt types: list, checkbox, choice, input, confirm, password, number, toggle, editor, search, key press
  • Multi-column layouts with automatic terminal width adaptation
  • Grid-based navigation using arrow keys
  • Script integration via PromptCommands for shell scripts and automation
  • Full backward compatibility with the Console UI API

See Prompt Module.

Terminal Providers​

JLine 4 replaces the Jansi and JNA providers with modern alternatives.

ProviderJLine 3JLine 4Notes
FFM--NewForeign Function & Memory API (Java 22+), best performance
JNI--NewJava Native Interface, works on Java 11+
JansiYesRemovedUse JNI or FFM instead
JNAYesRemovedUse JNI or FFM instead
ExecYesYesExternal commands (stty, tput), no native access needed
DumbYesYesPure-Java fallback

Default provider order: FFM, JNI, Exec (Dumb is fallback-only).

Migrating from Jansi​

If you used Jansi purely for ANSI output, JLine 4's AttributedString.toAnsi() is a direct replacement — no AnsiConsole.systemInstall() needed. See Terminal Providers: Migrating from Jansi.

New Terminal Features​

Terminal Graphics​

Display images directly in the terminal via multiple protocols:

  • Sixel — widely supported (xterm, iTerm2, foot, WezTerm)
  • Kitty Graphics Protocol — modern, feature-rich
  • iTerm2 Inline Images — iTerm2-specific

A unified TerminalGraphics interface handles protocol detection and fallback automatically. See Terminal Graphics.

Grapheme Cluster Support​

Proper handling of combining characters, emoji, and complex scripts via Unicode Mode 2027 (DECRQM probing). Updated to Unicode 16.0. See Grapheme Cluster Mode.

Signal Handling via Panama FFM​

Modernized POSIX signal handling using Panama FFM sigaction(), providing better Ctrl-C and Ctrl-Z behavior without JNI overhead.

/dev/tty Fallback​

When stdin/stdout are piped (e.g., via exec-maven-plugin), JLine can now open /dev/tty directly to access the controlling terminal:

TerminalBuilder.builder().devTty(true).build();

JPMS Support​

JLine 4 provides full Java Platform Module System support with proper module-info.java descriptors:

  • org.jline.terminal — core terminal functionality
  • org.jline.terminal.ffm — FFM provider (Java 22+)
  • org.jline.reader — line editing
  • org.jline.style — styling and coloring
  • org.jline.builtins — built-in commands
  • org.jline.shell — shell framework
  • org.jline.prompt — prompt module

See JPMS documentation for module usage and migration details.

Deprecated APIs​

Console Module (jline-console)​

The old command infrastructure is deprecated but still functional. Bridge adapters are provided for migration:

Old (jline-console)New (jline-shell)
CommandRegistryCommandGroup
SystemRegistryCommandDispatcher
CommandMethods + CommandInputCommand.execute()
CmdDescCommandDescription
CmdLineCommandLine
ArgDescArgumentDescription

Use CommandGroupAdapter and CommandRegistryAdapter to bridge old and new APIs. See Shell: Migration Guide.

Console UI Module (jline-console-ui)​

Still functional but superseded by the Prompt Module, which offers the same API with multi-column layouts, more prompt types, and better performance.

Migration Checklist​

  1. Update Java version to 11 or higher
  2. Update Maven version to 3.9 or higher
  3. Update dependency coordinates:
    <dependency>
    <groupId>org.jline</groupId>
    <artifactId>jline</artifactId>
    <version>4.4.3</version>
    </dependency>
    Use <classifier>jdk11</classifier> if targeting Java 11-21.
  4. Remove Jansi/JNA dependencies — native access is built-in via JNI and FFM
  5. Migrate Console API to Shell if writing new code (or use adapters for existing code)
  6. Migrate Console UI to Prompt module for new prompt code
  7. Add --enable-native-access if using Java 22+ with modules:
    --enable-native-access=org.jline.terminal.ffm
  8. Test on target platforms — provider auto-selection handles most cases