htop description here. In questions about getch
, I saw statements like "console is different under every system". But JVM implementation is also different under every system.
Well, the comments below show that my question doesn't represent the simplicity of the problem. Some related questions are:
- Equivalent function to C's “_getch()” in Java>
- Reading a single char in Java (see the comments)
- Tab Based Autocomplete in Console App
- how can I detect arrow keys in java? (This is implicitly only about AWT though)
- Recognize arrow keys in Java Scanner or Console application.
- ... curses-like, library for terminal applications? (100 upvotes, closed for not meet though...)
As for me, they are, in part, derivatives of the lack of C conio.h like functionality. Some of the questions address much more complex tasks than reading ➡ key. And there some 3rd party libraries for solving them jline3, jCurses. But besides they are 3rd party and solving their own complex tasks, they have to deal with the specific terminal settings, JNI, or JNA because of the original problem. So, what if the task is jast to read a letter or arrow button after it had been typed?
Outside Java world, there projects like GNU Readline, curses. But unlike pure-Java projects, they can't benefit from "run anywhere" VM. Maybe some SIM-cards don't have terminal capabilities. On the other hand, AWT, which needs much more hardware capabilities than terminal, was implemented. Cause it was considered worthy, I guess. And nowadays more and more SoCs are capable of X11, not even terminal. So, are full-fledged terminals so uncommon, and their functionality implementation on various systems so diverse, that instruments for its straightforward implementation have no place in Java SE?