System.console() returns null in Eclipse but works from command line [message #245438] |
Tue, 10 July 2007 09:55  |
Eclipse User |
|
|
|
Originally posted by: sirko.rudolph.gmx.net
Hi,
this question was asked in the new users group last September but never
answered.
So I hope here is somebody who can help solving this problem.
In a very simple Java class I make a call to System.console() to get a
Console object. However, if I run the program in the Eclipse IDE the
System.console() returns null. If I run the same program from the command
line I actually get a Console instance and can work with it (e.g. using
the Reader() from the Console object).
Where can the problem be? I checked the run settings that "Allocate
Console" is checked. Also, if I just use System.in to get input from the
console it is working within the IDE but not with System.console().
Any hints would be highly appreciated.
I am using Eclipse 3.2.2, Build M20070212-1330
Thanks in advance,
Sirko
|
|
|
|
|
Re: System.console() returns null in Eclipse but works from command line [message #245855 is a reply to message #245672] |
Mon, 16 July 2007 12:21  |
Eclipse User |
|
|
|
If you launch a java program from the command line that launches a java
program, is the console available from the nested program? This is
effectively what the run/debug support does in Eclipse, so I would expect
the same behavior.
Darin Wright
"Sirko" <sirko.rudolph@gmx.net> wrote in message
news:226fb0e3cd311e991f3962322a1bf6bc$1@www.eclipse.org...
> Hi,
>
> thanks for the answer. Forgive me that I bother all of you again. But I
> did read exactly this excerpt from the Javadocs. What I do not know is
> what Eclipse does in the background when launching a program in the IDE.
>
> So for me it seams, that Eclipse is redirecting the standard input and
> output. Therefore the simple "new Scanner( System.in )" is working in the
> IDE because it's using the (redirected) InputStream of the IDE, while a
> Console object is not existing in the IDE.
>
> Is that right?
>
> Thanks all for your patience.
>
> Regards
> Sirko
>
|
|
|
Powered by
FUDForum. Page generated in 0.03450 seconds