Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-3073

Can't get Console input with Gradle project

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 11.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows 10 x64 version 1803

      Description

      When trying to build a console application with Gradle in Netbeans, it can't get the user input.

      For example, running this code:

      public class Main {
          public static void main(String[] args) {
              try(Scanner sc = new Scanner(System.in)){
                  String s = sc.nextLine();
                  System.out.println(s);
              }
          }  
      }
      

      result in the error

      Exception in thread "main" java.util.NoSuchElementException: No line foundException in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at test.Main.main(Main.java:21)
      

      ---- * This happens when running the project from Netbeans (running it via java cli in terminal works)

      • The error happen before the user can enter anything in the "output" panel
      • The error happens on both JDK 1.8 and OpenJDK11 at least
      • The error only happen with Gradle projects, not with Ant projects

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vincent456 Vincent Hudry
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: