Gradle's standard input is not bound to the system's standard input by default, and needs to be set manually.
refer to:/questions/13172137/console-application-with-java-and-gradle
question
In the console program built by Gradle, the standard input readLine always returns null
reason
Gradle's standard input is not bound to the system's standard input by default, and needs to be set manually.
Solution
Add in
<JavaExec>("run") { standardInput = System.`in` }
If you need cleaner output, you can use
gradle console:run -q --console=plain
Solution (Groovy)
Add in
run { standardInput = }
Replenish:Handle the problem of using jline in IDEA development environment that cannot work properly
Phenomenon: When developing applications in IDEA, when using jline to capture console input, it cannot run normally. It is mainly reflected in the fact that the following code cannot be executed after inputting and entering:
ConsoleReader reader = new ConsoleReader();
("> ");
Solution:
Before using jline, execute the following code:
(, );
You can also add parameters to the command line when the program starts.
-=
This is the article about the solution to the inability to use readLine normally in Gradle/IDEA. For more related ideas that cannot use readLine normally, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!