java.util.scanner throws NoSuchElementException when application is started with gradle run

You must wire up default stdin to gradle, put this in build.gradle:

run {
    standardInput = System.in
}

UPDATE: 9 Sep 2021

As suggested by nickbdyer in the comments run gradlew run with --console plain option to avoid all those noisy and irritating prompts

Example

gradlew --console plain run

And if you also want to completely get rid of all gradle tasks logs add -q option

Example

gradlew -q --console plain run

Leave a Comment