Left arrow button is not working in the ouput console
Hi,
I am new to Linux. I am having a java program which will read characters from console. i have started my program from bash shell and now the program starts and waiting for the inputs. Say I have typed text , "hello". If i try to move the cursor position back wards using the left arrow button it was not working. Instead some junk characters are printed on the console like ^[[C . Please see the out put text below. hello^[[C^[[C^[[C^[[C^[[C Below is my program. public static void main(String as[]) { BufferedWriter outputWriter = new BufferedWriter(new PrintWriter(System.out)); BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in)); String command = null; try { while (true) { command = inputReader.readLine(); outputWriter.write("The command is " + command); } } catch (Exception e) { } } } Note: In windows its working fine. Thanks in advance. Sree |
Does the left arrow key work at the console when your Java program is not running? What exactly is the console? What is the value of $TERM?
|
1 Attachment(s)
Quote:
Thanks, Sree |
Is the console a terminal emulator, a virtual terminal, a physical terminal on a serial port, running an ssh session ... ? The value of $TERM might help. What does the Java program do to read from the console? Which device does or file descriptor does it open and with which options? Do the other cursor movement keys all work OK?
|
If you want line editing features like bash has you'll need something like Java Readline or JLine.
|
Quote:
Thanks in advance, Sree |
append "stty erase" in your shell profile and try re-login to your account.
Remember, in windows things will work fine except blue screen. But in Linux every thing will work better than what we expect. What we have to do is, we have to use our "BRAIN". With out practicing and understanding the concepts you can't work in Linux. Pl Don't consider this as rude. Best Regards Happy Programming. |
All times are GMT -5. The time now is 04:58 AM. |