title: Wait for user input while debugging on IntelliJ IDEA and Gradle
body: <p>I have the simplest Java application that just works if executed from command line. But if I want to debug it through IntelliJ IDEA 14 Ultimate, the <code>System.in.read()</code> part always returns <code>-1</code>, without ever typing anything into it:</p>
  
  <pre><code>import java.io.IOException;
  
  public class Main {
      public static void main(String[] args) throws IOException {
          System.out.println("This is a test... Hit [enter] to exit.");
          int cha = System.in.read();
          System.out.println("You hit [enter], exiting...");
      }
  }
  </code></pre>
  
  <p>Is this some kind of issue with Windows 8.1 or is it IntelliJ IDEA related?</p>
  
  <p><strong>UPDATE</strong>: I have found out the issue presents itself only when starting the application through Gradle (<em>gradlew run</em>), so it's a Gradle issue. This is my <code>build.gradle</code>:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'application'
  
  sourceCompatibility = 1.7
  targetCompatibility = 1.7
  version = '1.0'
  mainClassName = 'net.frakbot.ws.Main'
  
  repositories {
      mavenCentral()
  }
  
  run {
      main = 'net.frakbot.ws.Main'
      standardInput = System.in
  }
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version: '4.11'
  }
  </code></pre>