0

I have a simple class Main,

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.println(scanner.nextLine());
}

When I start it from IDEA, everything works fine, but when I start my application from the console - I get Exception in thread "main" java.util.NoSuchElementException: No line found

I use gradle, start with the gradle task

task runApplication(type: JavaExec) {
    dependsOn jar

    classpath += files(jar.getArchiveFile())
    classpath += sourceSets.main.runtimeClasspath

    main = "com.Main"
}

Running on Windows 7 with Java 1.8

user85421
  • 28,957
  • 10
  • 64
  • 87
a3dsfcv
  • 1,146
  • 2
  • 20
  • 35
  • Thanks, but run { standardInput = System.in } Gives me an error: Could not find method run() for arguments [.....] Runnung gradle 5.5.1 – a3dsfcv Oct 07 '19 at 21:52
  • 1
    Please adapt the solution to your particular file and naming convention. Put `standardInput = System.in` inside your `runApplication` task – that other guy Oct 07 '19 at 22:01

0 Answers0