LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-06-2010, 06:51 AM   #1
Sreevisakh
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Rep: Reputation: 0
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
 
Old 12-06-2010, 07:08 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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?
 
Old 12-07-2010, 07:52 AM   #3
Sreevisakh
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Question

Quote:
Originally Posted by catkin View Post
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?
Thanks for the response. Yes the left arrow is functioning properly for the console when the program is not running. I have started the program from a bash shell. Here by console what I meant is the place where the output of the java program is displayed. This is actually the same bash shell from which the program runs. I have given an attachment which shows the output and terminal details here. Please see it.

Thanks,
Sree
Attached Thumbnails
Click image for larger version

Name:	java output.GIF
Views:	12
Size:	2.2 KB
ID:	5412  
 
Old 12-07-2010, 07:57 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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?
 
Old 12-07-2010, 10:07 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,256

Rep: Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421Reputation: 1421
If you want line editing features like bash has you'll need something like Java Readline or JLine.
 
1 members found this post helpful.
Old 12-09-2010, 01:06 AM   #6
Sreevisakh
LQ Newbie
 
Registered: Dec 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
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?
This program runs from a normal xterm terminal from a Linux machine. The java program starts and it will wait for the input texts the user enters into the console. The problem is there for all the movement keys. The program simply get the value from the console. It's not using any seperate file or device descriptor.

Thanks in advance,
Sree
 
Old 12-09-2010, 01:43 AM   #7
prodev05
Member
 
Registered: Jul 2009
Location: Planet Earth
Distribution: Unix & Linux Variants
Posts: 304

Rep: Reputation: 20
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VT100 Emulated Left Arrow Key Suppressed cmnorton Linux - General 0 02-23-2010 12:01 PM
screen / screenrc: how to use the right / ctrl arrow to go left and right in windows? frenchn00b Linux - General 6 11-10-2009 02:11 PM
about xwindow. mouse left button and right button chuangsheng Programming 4 06-13-2009 01:34 AM
holding down left and down arrow does not repeat dave201 Linux - General 1 11-22-2008 05:19 PM
[Dell d830] Keyboard left and up arrow act strange v1pEr Linux - Hardware 0 03-28-2008 06:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration