Java挂起了linux上的用户输入?

时间:2022-03-23 00:24:33

I've been trying to do my UW assignment for a few hours now, and I've managed to work my way back to the understanding that user input isn't working. I'm using the scanner class and console.nextLine(); to read in the user's string, but just hangs and won't read in the input when I press enter.

我一直在努力完成我的UW任务几个小时,我已经设法恢复了用户输入无效的理解。我正在使用scanner类和console.nextLine();读取用户的字符串,但只是挂起,按Enter键时不会读入输入。

I'm using eclipse, but I tried to do the same thing in netbeans and it still didn't work, and I'm running Linux Mint 11. I've tried restarting my computer, killing the eclipse task and restarting it, and I've asked several other linux users who program, but none of them have a clue. Please help?

我正在使用eclipse,但我尝试在netbeans中做同样的事情,但它仍然无法工作,我正在运行Linux Mint 11.我已经尝试重新启动计算机,杀死eclipse任务并重新启动它,以及我问了其他几个编程的linux用户,但他们都没有任何线索。请帮忙?

1 个解决方案

#1


0  

Easy and very detailed, step-by-step guide, which demonstrate how to use Java Scanner class and read user input. Check in your code for infinite loops.

简单而详细的分步指南,演示如何使用Java Scanner类和读取用户输入。检查代码中的无限循环。

If you're completely sure your code is correct, you might have bad environment setup. I am linux user, and I know most distributions come with openJDK, which is more-or-less fine (until you hit Swing). Also sun JDK is now available only from third-party repositories and not in the official ones. Can you post output from the following commands

如果您完全确定您的代码是正确的,那么您可能会设置错误的环境。我是linux用户,我知道大多数发行版都附带openJDK,它或多或少都很好(直到你点击Swing)。 sun JDK现在只能从第三方存储库获得,而不是官方存储库。你可以发布以下命令的输出吗?

java -version
echo $JAVA_HOME
echo $PATH

Have you tried to run a HelloWorld program, just to test your environment is correct? If you can run other projects successfully, it's clear the problem is in your code. If that's the case, provide the parts of your code, that you can think are problematic.

您是否尝试过运行HelloWorld程序,只是为了测试您的环境是否正确?如果您可以成功运行其他项目,则很明显问题出现在您的代码中。如果是这种情况,请提供您认为有问题的代码部分。

#1


0  

Easy and very detailed, step-by-step guide, which demonstrate how to use Java Scanner class and read user input. Check in your code for infinite loops.

简单而详细的分步指南,演示如何使用Java Scanner类和读取用户输入。检查代码中的无限循环。

If you're completely sure your code is correct, you might have bad environment setup. I am linux user, and I know most distributions come with openJDK, which is more-or-less fine (until you hit Swing). Also sun JDK is now available only from third-party repositories and not in the official ones. Can you post output from the following commands

如果您完全确定您的代码是正确的,那么您可能会设置错误的环境。我是linux用户,我知道大多数发行版都附带openJDK,它或多或少都很好(直到你点击Swing)。 sun JDK现在只能从第三方存储库获得,而不是官方存储库。你可以发布以下命令的输出吗?

java -version
echo $JAVA_HOME
echo $PATH

Have you tried to run a HelloWorld program, just to test your environment is correct? If you can run other projects successfully, it's clear the problem is in your code. If that's the case, provide the parts of your code, that you can think are problematic.

您是否尝试过运行HelloWorld程序,只是为了测试您的环境是否正确?如果您可以成功运行其他项目,则很明显问题出现在您的代码中。如果是这种情况,请提供您认为有问题的代码部分。