This is a translated and condensed guide to Java TUI (text user interface) frameworks, covering their features, use cases, and how to choose between them.
1. Core Framework Comparison
Lanterna — curses-inspired, pure Java
- 100% pure Java, no native dependencies; runs anywhere Java runs (Windows, Linux, macOS), ideal for containers and restricted servers.
- Supports multiple terminal backends: a Swing-based virtual terminal, Unix terminals (via
stty), and Windows CMD/PowerShell. - Rich component set (
Panel,Window,Button,TextBox,CheckBox,ListBox, etc.) plus layout managers (GridLayout, LinearLayout). - Unusually for TUI libraries, supports mouse interaction.
- Swing-like API gives a gentle learning curve for Java GUI developers; mature docs and community.
- Downsides: relatively heavy for tiny scripts; component/event model still requires learning for newcomers.
- Inspired by Borland's Turbo Vision; acts like a full terminal window manager with overlapping, draggable, resizable windows, menu bars, and dialogs.
- Advanced features: Sixel image support (bitmap rendering in terminals, requires capable terminals like
xterm) and a built-in terminal multiplexer (similar totmux/screen). - Suited to IDE-like tools, database clients, system monitors, full text editors.
- Steeper learning curve; Sixel features depend on terminal support.
- Maintenance status: once labeled "unmaintained," but version 1.7.0 was released April 29, 2025 on SourceForge, indicating renewed activity. Verify latest release status before committing.
- Focused on input handling: inline editing with Emacs and Vi key bindings, command history (including
Ctrl+Rsearch), and extensible tab completion. - Also supports syntax highlighting.
- Powers well-known tools such as Groovy Shell and JRuby IRB; lightweight with few dependencies.
- Provides no GUI components — pair it with Lanterna/Jexer if you need windows.
- Higher-level than JLine, simpler than Lanterna. Fluent API:
newStringInputReader(),newIntInputReader(),newBooleanInputReader(), etc., with chained prompt, default-value, and validation configuration (range checks, option lists). - Multiple input sources: console, files (for automation/testing), and Swing dialogs; hides password input.
- Ideal for installers, wizards, and multi-step configuration flows; not suited for complex layouts or dynamic screen refresh.
- Ultra-lightweight MIT-licensed library reducing I/O boilerplate. Key classes:
Terminal(e.g.,Terminal.readInt("Please state your age: ")handles prompts, parsing, retries) andUnclosableInputStream(aSystem.inwrapper whoseclose()is a no-op, preventing accidental stream closure). - Only basic text I/O — no layout, events, or screen control.
- JCurses: wraps native
ncursesvia JNI; capable but complicates deployment due to native dependencies. - CHARVA: Swing-like API for TUIs, also JNI-based; abandoned — site offline, no updates for years.
- TUIAWT: an innovative text-mode Look-and-Feel for AWT using pluggable
java.awt.peerinterfaces, rendering via a remotetuipeerprogram over sockets — enabling multi-user server JVMs and "one codebase, two interfaces." Last updated March 1, 2015; only supports JDK 1.1.8 and earlier, as Java 2+ hardcodedsun.awt.SunToolkit. - Simple tools/scripts: choose
java-tui(minimal) orText-IO(when you need validation). - Mid-complexity interactive apps (wizards, config tools): choose
Text-IO; chooseJLineif the core is an interactive shell/REPL. - Full-featured TUI apps (DB clients, monitors, file managers, terminal IDEs): choose
Jexerfor maximum features; chooseLanternafor a mature, gentler learning curve. - Multi-window, mouse, images, complex layout →
Jexer - Command-line editing, history, completion →
JLine - Typed, validated user input →
Text-IO - All four main frameworks are pure Java with no native dependencies, so cross-platform compatibility is excellent.
LanternaandJexerinclude built-in Swing terminal emulators, so apps run and can be debugged with breakpoints directly inside IDEs.- Avoid JNI-dependent legacy libraries (JCurses, CHARVA) in containerized or security-restricted deployments.
- "J 商品" is not a real Java TUI library — searches only surface e-commerce web projects (SpringBoot/Vue shops). It appears to be a misremembered name and should not factor into TUI selection.
- "TUIKit" in the Java ecosystem usually refers to Tencent Cloud's IM UI component library (TUIChat, TUIConversation, TUIContact, TUIGroup, TUISearch, TUICallKit), built on the Tencent IM SDK for Android, iOS, Web (Vue2/Vue3), and WeChat Mini Programs — an instant-messaging UI solution, not a terminal UI framework.
- "Tuikit" also names a Rust TUI library inspired by
termbox(thread-safe, fullscreen/windowed modes, mouse and Alt-key event handling). It is unrelated to Java; distinguish by language when researching.