Quantcast
Channel: JetBrains Developer Community : Thread List - IntelliJ IDEA Users
Viewing all articles
Browse latest Browse all 5661

Unable to use java/groovy console while debugging

$
0
0

I have a very simple groovy script that reads a username and password from the console. If I run the script from the command line it works perfectly. However, if I try to run it from within Intellij, the console is null.

 

How can I read console input while debugging my script?

 

 

String username
String password 
def console = System.console()if (console) {    username = console.readLine('> Please enter your username: ')    password = new String(console.readPassword('> Please enter your password: '))    println "username: ${username} password: ${password}"}else{    println "Cannot get console, exiting..."    System.exit(1)}

Viewing all articles
Browse latest Browse all 5661

Trending Articles