I am writing a console based Java application in which the user will be presented a custom command prompts where she can type certain commands, I want to implement an auto complete feature for the app by which while typing the command, if the user presses TAB then the command should complete. The functionality is similar to auto complete in Linux command prompt.
In Java Console App we don't get the control over TAB and a TAB pressed will by default append 8 spaces. I need some trick using which the TAB doesn't go for rendering and my app can replace the TAB with autocomplete.
Thanks in advance.
You can try using a library like Java-Readline or jline2.
The picocli Java command line parsing library recently added autocomplete functionality.
You may also like how it enables you to use ANSI colors and styles in the usage help message.
Disclaimer: I am the author and therefore biased.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With