0

I am currently using:

Scanner scanner = new Scanner(System.in);

To get user input in Java, but I want to add a way for user to use previous command easily. If users presses UP key it should show previous command instead of ^[[A. It shouldn't suggest after I press enter. It should work like in bash. For example, I can type arrow key it displays previous command, I can modify it and then press enter to send command. Is it possible in Java? I tried using libraries like JLine, but I could get it working.

3
  • I never like to use the word 'impossible' but let's use it here for the sake of helping you. Impracticable
    – g00se
    Commented Aug 8, 2023 at 10:26
  • Can you tell why? I am developing a way to send commands, and it would be really great if this feature would work as I described. Is it possible in other languages? But I would prefer to stay in Java.
    – Norbiros
    Commented Aug 8, 2023 at 10:37
  • Because it would require native code. So it wouldn't be cross-platform for one thing. It goes beyond key listening to the storage of key strokes
    – g00se
    Commented Aug 8, 2023 at 10:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.