Java 使用gradlew run时,System.getConsol()返回null
我的Java应用程序需要提示用户输入密码。为了做到这一点(并且为了维护安全性),我们正在使用Java 使用gradlew run时,System.getConsol()返回null,java,gradle,console,Java,Gradle,Console,我的Java应用程序需要提示用户输入密码。为了做到这一点(并且为了维护安全性),我们正在使用System.getConsole().readPassword()。 但是,当通过gradlew clean runSystem启动应用程序时,getConsole()返回null 这是我的申请表 public static void main(final String[] args) throws Exception { Console CONSOLE = System.consol
System.getConsole().readPassword()。
但是,当通过gradlew clean run
System启动应用程序时,getConsole()返回null
这是我的申请表
public static void main(final String[] args) throws Exception {
Console CONSOLE = System.console();
if (CONSOLE == null) {
System.err.println("No console.");
System.exit(1);
}
char[] password = CONSOLE.readPassword(consoleMessage);
}
这是我的build.gradle文件:
apply plugin: 'application'
mainClassName = "com.emc.ia.main.impl.PasswordEncryptor"
如果有人能提供任何帮助,我们将不胜感激
谢谢 您使用的是IDE吗?不只是命令行吗?您使用的是IDE吗?不只是命令行