Raspbian rc.localでJavaコンソールアプリケーションを実行しようとしています。rc.localのJavaコンソールアプリケーションでのキーボードの問題
キーボード入力に基づいてメニュー項目を選択するためのブートメニューです。 コマンドプロンプトで実行している場合、プログラムは正常に動作します。
rc.localに
java -jar /home/pi/RaspPiStartup/RaspPiStartup.jar
内のJavaコンソールアプリケーションの起動時にただし、アプリケーションはキーボード入力を読み取ることができません。
Scanner in = new Scanner(System.in);
Console con=System.console();
AtomicInteger num=new AtomicInteger(-1);
Thread thread = new Thread() {
public void run() {
try {
int i1;
if (con==null) {
System.out.println("KeyScan In");
i1=in.nextInt();
System.out.println("KeyScan "+i1);
}
else {
System.out.println("KeyCon In");
i1=Integer.parseInt(con.readLine());
System.out.println("KeyCon "+i1);
}
num.set(i1);
}
catch(Exception e) {
System.out.println("Fehler Keyboard In"+e.toString());
}
}
};
thread.start();
ご覧のとおり、いくつかの方法を試しました。 このソリューションは私に例外を与えます。 rc.localのcon == nullの場合、スキャナは読み取りを試みます。 したがって、java.util.NoSuchElementExceptionが発生します。
rc.localのキーボード入力を読み込むには何が必要ですか? おかげで...