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

Console does not allow input with Scanner class / Gradle Project

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 11.0, 11.2, 11.3
    • None
    • None

    Description

      When using the scanner class, Netbeans 11.0, 11.2 and 11.3 still does not allow user input in the console like the scanner class should normally do. Here is a link to a similar issue and it has not been resolved https://issues.apache.org/jira/browse/NETBEANS-3073

      I get the following error. 

      > Task :run FAILED> Task :run FAILEDEnter your ageException in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at gradleproject1.Main.main(Main.java:23)
      FAILURE: Build failed with an exception.

      • What went wrong:Execution failed for task ':run'.> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
      • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

       

      I have tried with both Java SE Development Kit 11(LTS) and 8u241 on Netbeans 11.0, 11.2 and the latest 11.3 Apache version and I still get the same error.

      Here is some simple code below that works in Eclipse but not in Netbeans because of this issue. 

      import java.util.Scanner;
      
      /**
      *
      * @author noahavelar
      */
      public class Main {
      
      /**
      * @param args the command line arguments
      */
      public static void main(String[] args) {
      // TODO code application logic here
      Scanner input = new Scanner(System.in);
      System.out.println("Enter your age");
      int theNumber = Integer.parseInt(input.nextLine());
      
      System.out.println(theNumber);
      
      System.out.println("Enter your name");
      String myName = input.nextLine();
      
      System.out.println(myName);
      
       
      
      }
      
      }
      

      Attachments

        1. image-2020-04-04-10-18-09-675.png
          223 kB
          Laszlo Kishalmi

        Activity

          People

            Unassigned Unassigned
            carnage47 Noah Avelar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 504h
                504h
                Remaining:
                Remaining Estimate - 504h
                504h
                Logged:
                Time Spent - Not Specified
                Not Specified