LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 05: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, 06:08 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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, 06: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:	25
Size:	2.2 KB
ID:	5412  
 
Old 12-07-2010, 06:57 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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, 09:07 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
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, 12: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, 12: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



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 11:01 AM
screen / screenrc: how to use the right / ctrl arrow to go left and right in windows? frenchn00b Linux - General 6 11-10-2009 01:11 PM
about xwindow. mouse left button and right button chuangsheng Programming 4 06-13-2009 12:34 AM
holding down left and down arrow does not repeat dave201 Linux - General 1 11-22-2008 04:19 PM
[Dell d830] Keyboard left and up arrow act strange v1pEr Linux - Hardware 0 03-28-2008 05:58 AM

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

All times are GMT -5. The time now is 02:36 PM.

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
Open Source Consulting | Domain Registration