This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 195380 - System.console() returns null
Summary: System.console() returns null
Status: RESOLVED DUPLICATE of bug 68770
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 7.0
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-12 12:59 UTC by vanob
Modified: 2011-02-14 15:41 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vanob 2011-02-12 12:59:03 UTC
[ BUILD # : 201102111519 ]
[ JDK VERSION : 1.6.23 ]

I've created Java Application project with the default settings.
In the main method I have the code:

Console con = System.console();
        if (con != null) {
            String s = con.readLine();
            System.out.println(s);
        }
        
        Scanner s = new Scanner(System.in);
        System.out.println(s.nextLine());

If I run this program from IDE it only prompts once to enter something.
But if I run it from cmd window, it prompts twice.

I guess System.console() should not return null in NetBeans IDE
Comment 1 Jesse Glick 2011-02-14 15:41:30 UTC
System.console() is only available from a true terminal, which Ant-based program execution is not. For now such programs can be run outside NetBeans, or using Window > Output > Terminal.

*** This bug has been marked as a duplicate of bug 68770 ***