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