I'm not entirely certain how your questions about the console relate to your
first point about getting input via buffers.  Java newcomers will have to
deal with Exceptions.  They are part of what make the platform and language
robust.  That said, I don't see how introducing a newcomer to the console is
any easier :)

I think your second question is answered by this bit in the documentation
for Console:

*If the virtual machine is started from an interactive command line without
redirecting the standard input and output streams then its console will
exist and will typically be connected to the keyboard and display from which
the virtual machine was launched. * *
*
*If the virtual machine is started automatically, for example by a
background job scheduler, then it will typically not have a console.*
*
*
*If this virtual machine has a console then it is represented by a unique
instance of this class which can be obtained by invoking the **
System.console()*<http://java.sun.com/javase/6/docs/api/java/lang/System.html#console()>
* method. If no console device is available then an invocation of that
method will return **null**.*

I would guess that in the case of NetBeans and Eclipse, the jvm is started
while loading these applications, not explicitly via a command line.  With
no command line associated, you will get a null.

On Tue, Jul 14, 2009 at 15:42, Diogo Sales Oliveira
<[email protected]>wrote:

>
> Hi all
>
> I was experimenting with LAB-1003 hands-on, where we're taught to get
> input from keyboard accessing stardard input in a buffered way. But the
> way I see it, there are two problems:
>
> - We have to handle the exceptions from such generic classes like
> BufferedReader and InputStreamReader.
> - Appears complex to grasp to the java newcomer
>
> I then found out that since Java 6.0 there's a new java.io class,
> Console, whose object is returned by System.console():
> public static Console
> <http://java.sun.com/javase/6/docs/api/java/io/Console.html> *console*()
> Returns the unique |Console|
> <http://java.sun.com/javase/6/docs/api/java/io/Console.html> object
> associated with the current Java virtual machine, if any.
> *Returns: T*he system console, if any, otherwise null.
>
> More information on Console's API javadoc's. It almost seems like
> something every java programmer been expecting. The problem is that,
> neither using Netbeans not Eclipse, the System console seems to be
> unavaliable. It works fine on the command line, but System.console()
> returns null when running through the IDE.
>
> I'm guessing that's because the JVM is handled in a different way. But I
> can't quite understand it. Can anyone explain why it doesn't work? Or if
> is there a workaround to make it work?
>
> Hugs
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to