🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
5 messages
5 total messages Started by Vander Wed, 16 Mar 2005 09:22
Keyboard Input?
#602
Author: Vander
Date: Wed, 16 Mar 2005 09:22
6 lines
1410 bytes
Perhaps a bit off the swing topic, but I wonder if it is possible to 
obtain direct keyboard character/signal input from the console. 
System.in only reads lines of text and echoes all characters. For a 
commandline utility I need to perform password input, so to echo only 
"*" instead of the text. - Can somebody know a solution or can give me 
directions? Thanks!
Re: Keyboard Input?
#603
Author: Lori M Olson [TeamB]
Date: Wed, 16 Mar 2005 19:09
30 lines
2010 bytes
Vander wrote:

> Perhaps a bit off the swing topic, but I wonder if it is possible to 
> obtain direct keyboard character/signal input from the console. 
> System.in only reads lines of text and echoes all characters. For a 
> commandline utility I need to perform password input, so to echo only 
> "*" instead of the text. - Can somebody know a solution or can give me 
> directions? Thanks!
> 

http://java.sun.com/features/2002/09/pword_mask.html

-- 

Regards,

Lori Olson [TeamB]

------------

Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.

Google Advanced Newsgroup Search
     http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
     http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
     http://www.visi.com/~gyles19/fom-serve/cache/1.html
Re: Keyboard Input?
#604
Author: John McGrath [TeamB]
Date: Wed, 16 Mar 2005 22:00
24 lines
1783 bytes
On 3/16/2005 at 4:22:12 AM, Vander wrote:

> Perhaps a bit off the swing topic, but I wonder if it is possible to
> obtain direct keyboard character/signal input from the console.
> System.in only reads lines of text and echoes all characters. For a
> commandline utility I need to perform password input, so to echo only
> "*" instead of the text. - Can somebody know a solution or can give me
> directions? Thanks!

There is nothing in Java that allows this level of control over console
input.  To do this with console input, you would need to use some sort of
native library.  An alternative approach would be to use a GUI console
window, such as the JConsole class that comes with BeanShell:

   http://www.beanshell.org/

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Re: Keyboard Input?
#607
Author: Vander
Date: Thu, 17 Mar 2005 08:16
32 lines
2143 bytes
Many thanks both of you, very interesting hints!
In particular the BeanShell approach seems promising. Another question 
that arises is if somebody tries to mimic an operating system prompt in 
a JConsole, could you possibly redirect system console output of other 
programs (e.g. service commands) into the Java application that runs the 
JConsole?


John McGrath [TeamB] wrote:

>On 3/16/2005 at 4:22:12 AM, Vander wrote:
>
>  
>
>>Perhaps a bit off the swing topic, but I wonder if it is possible to
>>obtain direct keyboard character/signal input from the console.
>>System.in only reads lines of text and echoes all characters. For a
>>commandline utility I need to perform password input, so to echo only
>>"*" instead of the text. - Can somebody know a solution or can give me
>>directions? Thanks!
>>    
>>
>
>There is nothing in Java that allows this level of control over console
>input.  To do this with console input, you would need to use some sort of
>native library.  An alternative approach would be to use a GUI console
>window, such as the JConsole class that comes with BeanShell:
>
>   http://www.beanshell.org/
>
>  
>
Re: Keyboard Input?
#608
Author: John McGrath [TeamB]
Date: Thu, 17 Mar 2005 19:41
24 lines
2092 bytes
On 3/17/2005 at 3:16:25 AM, Vander wrote:

> Another question that arises is if somebody tries to mimic an operating
> system prompt in a JConsole, could you possibly redirect system console
> output of other programs (e.g. service commands) into the Java
> application that runs the JConsole?

If you run another program using Runtine.exec(), you have a pipe to the
stdin/stdout/stderr of the process.  I think you should be able to hook
those into a JConsole.

I know that JConsole provides line editing, and I do not know if you can
turn that off, so there may some issues if you need character-by-character
input in the program you run.  It may be that JConsole will only send an
entire line at a time.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads