gpt4 book ai didi

java - 屏蔽控制台输入的密码: Java with nohup command

转载 作者:太空宇宙 更新时间:2023-11-04 04:21:35 25 4
gpt4 key购买 nike

我有一个应用程序,在输入以下命令后,我禁用了密码字段的回显:

java -cp testJar.jar testClassFileInJar username

其中 username 是提供给类 testClassFileInJar 的 main 方法的参数。按回车后,会提示输入密码。当我尝试以下命令时,我无法使其运行,并且 java1.out 文件也是空的。

nohup java -cp testJar.jar testClassFileInJar username & > java1.out

请提出建议。总而言之,我需要在 java1.out 文件中完成日志记录,并需要与此 java 命令一起使用 nohup 命令。

我在 main 方法中使用了以下代码:

Console console = System.console();
String userName = args[0];
String password = String.valueOf(console.readPassword("Password: "));
//other code logic for processing username and password

最佳答案

请尝试以下操作:

nohup java -cp testJar.jar testClassFileInJar username > java1.out &

关于java - 屏蔽控制台输入的密码: Java with nohup command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12616273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com