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 System.in.read()
part always returns -1
, without ever typing 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 issue with Windows 8.1 or is it IntelliJ IDEA related?
UPDATE: I have found out the issue presents itself only when starting the application through Gradle (gradlew run), so it's a Gradle issue. 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'
}
It is has been a known bug in Intellij Idea: bug description
EDIT: Apparently, as pointed out in the comments, it has been fixed since this answer was given and patched Intellij will be released in Summer 2017.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With