Wait for user input while debugging in IntelliJ IDEA and Gradle

I have a simple Java application that just works if executed from the command line. But if I want to debug it through IntelliJ IDEA 14 Ultimate, then the System.in.read() always returns -1 without entering anything into it:

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

Is this some kind of problem with Windows 8.1 or is it related to IntelliJ IDEA?

UPDATE . I found out that the problem only occurs when starting the application through Gradle (gradlew run), so this is the Gradle problem. This is my 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' } 
+4
source share
2 answers

It works fine on my Windows 7 machine with the IntelliJ IDEA 14 community.

+1
source

It is a known bug in Intellij Idea: error description

EDIT: Apparently, as noted in the comments, it was fixed as this answer was given and corrected Intellij will be released in the summer of 2017.

+1
source

All Articles