在IntelliJ IDEA和Gradle上调试时等待用户输入

我有最简单的Java应用程序,只有从命令行执行才能工作。 但是,如果我想通过IntelliJ IDEA 14 Ultimate调试它, System.in.read()部分总是返回-1 ,而不会输入任何内容:

 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..."); } } 

这是Windows 8.1的某种问题还是IntelliJ IDEA相关?

更新 :我发现只有在通过Gradle( gradlew run )启动应用程序时问题才出现,所以这是Gradle问题。 这是我的build.gradle

 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' } 

Intellij Idea中的一个已知错误: 错误描述

编辑:显然,正如评论中指出的那样,自从给出答案并修补后,它已被修复,Intellij将于2017年夏季发布。

它在我的带有IntelliJ IDEA 14社区版的Windows 7机器上运行良好。