Let’s say you want to program a game with a low level user interface (for example Pacman). But you don’t want to invest much time in the user-interface. So you take a look at existing libraries/frameworks providing user-interface functionality. The most popular ones are CHARVA  and Lanterna . But which one is better?
Lanterna vs CHARVA – Structure
CHARVA is a Java framework presenting “graphical” user interface. It can be structured in two components :
- Library of Java classes implementing serval “graphical widgets” (for example buttons, windows …)
- Dynamically-loaded shared library (written in C).
Lanterna on the other hand is a Java library which enables easy semi-graphical user interfaces. It is composed of 3 layers which are all written in Java :
- Low level terminal interface (googlecode.lanterna.terminal): Provides most basic control of the terminal text area like moving cursor/ putting characters to screen
- Full screen buffer (googlecode.lanterna.screen): Layer to put on top of a Terminal object. Allows you to write to this before flushing the changes to the actual terminal.
- Full GUI toolkit (googlecode.lanterna.gui): Provides windows, buttons, labels and other components
Lanterna vs CHARVA – Differences/Similarities
They both work with Swing and provide Maven dependencies, which makes them easy to use. The documentation in Lanterna and CHARVA isn’t great, but Lanterna provides a slightly better documentation. Furthermore instead of using the Maven dependency you can also just add the Lanterna jar file. Therefore there is no need for any prerequisites when using Lanterna. CHARVA however expects you to have Apache Ant installed [3, 4].
|Functionality compared to curses||Uses ncurses||Provides more functionality|
|Pure Java||No||Yes (independent of any native library)|
Figure 1 differences/similarities between CHARVA and Lanterna
But what about the functionality? Curses is a popular example for a terminal control library enabling the construction of text user interface applications . Ncurses (new curses) is a “free-software emulation (clone) of the System V Release 4.0 (SVr4) curses“. CHARVA uses ncurses. Lanterna is similar to curses but provides more functionality . But Laterna provides semi-graphical support whereas ncurses enables graphical support too .
Lanterna is the better choice regarding text and semi-graphical user interface functionality. But if you are searching for graphical user interface functionality choose CHARVA.