# Prompt user from command line

**URL:** <https://discuss.gradle.org/t/prompt-user-from-command-line/19779>\
**Category:** Help/Discuss\
**Created:** [September 28, 2016, 4:24pm UTC](https://discuss.gradle.org/t/prompt-user-from-command-line/19779 "2016-09-28T16:24:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kingdiepie](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@Kingdiepie](https://discuss.gradle.org/u/Kingdiepie)\
**Post date:** [September 28, 2016, 4:24pm UTC](https://discuss.gradle.org/t/prompt-user-from-command-line/19779/1 "2016-09-28T16:24:24Z")

</div>

I’m currently working on a program that takes information form google sheets and runs calculations. I use “gradle -q run” to run my program and I want it to prompt the user inside the terminal. Right now I am using scanner but it says “Enter your name: Exception in thread “main” java.util.NoSuchElementException” when I run instead of waiting for me to add a input, How do I fix this?

---

<div class="post-metadata">

**Author:** ![raleighr3](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/raleighr3/32/5378_2.png) [@raleighr3](https://discuss.gradle.org/u/raleighr3)\
**Post date:** [September 29, 2016, 12:38am UTC](https://discuss.gradle.org/t/prompt-user-from-command-line/19779/2 "2016-09-29T00:38:19Z")

</div>

The `run` task from the Application plugin is of type JavaExec  
see [The Application Plugin](https://docs.gradle.org/current/userguide/application_plugin.html)

If you look at the docs for [JavaExec](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html) you’ll see the problem is with the default value for stdIn (emphasis mine)

> standardInput | The standard input stream for the process executing the command. The stream is closed after the process  
> completes. **Defaults to an empty stream.**

Therefore you need to hookup standard in to `System.in`

something like this in your build.gradle should work:

```groovy
run {
    standardInput = System.in
}

```
