我试图在heroku上部署一个简单的Java程序,以从控制台获取输入。
代码如下:
public static void main(String[] args) throws Exception {
Scanner kboard = new Scanner(System.in);
System.out.println("\u000C");
String selection;
boolean video = true;
int cnt = 0;
while(video){
System.out.print("Enter cat or emu : ");
selection = kboard.nextLine();
if (selection.equals("emu")){
Desktop.getDesktop().open(new File("c:\\emu.mp4"));
Thread.sleep(14000);
}else if(selection.equals("cat")){
Desktop.getDesktop().open(new File("c:\\Cat Boarding.mp4"));
Thread.sleep(12000);
}
System.out.println();
cnt++;
if (cnt == 3) video = false;
}
kboard.close();
}
这是我得到的错误:
Enter cat or emu : Exception in thread "main" java.util.NoSuchElementException: No line found
2019-03-27T23:50:37.010138+00:00 app[web.1]: at java.util.Scanner.nextLine(Scanner.java:1540)
2019-03-27T23:50:37.010146+00:00 app[web.1]: at gen.P1.main(P1.java:18)