デスクトップJavaアプリケーションでは、たとえば、コンパイルする必要のないスクリプトを使用して、Javaアプリケーションを単独で再起動できました(リモートで何かを追加できるようにするため)。
デスクトップ スクリプト: restartme.sh
#!/bin/bash
export DISPLAY=:0.0
pkill java
java -cp SystemV.jar Main.Boot 0x01 &
# on the fly add new stuffs depending on the situations..
iperf -s -p 65000 &
convert -size 800x600 xc:transparent -font Bookman-DemiItalic -pointsize 50 -draw "text 25,90 ' inactive.'" -channel RGBA -blur 0x6 -fill steelblue -stroke white -draw "text 10,90 ' inactive.'" -antialias /var/www/html/video/now.jpeg;
x11vnc -forever -passwd x1x &
デスクトップ アプリケーション:
system("/var/tmp/restartme.sh &");
public static String system(String cmds) {
String value = "";
try {
String cmd[] = { "/bin/sh", "-c", cmds};
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
value += line + "\n\r";
line = reader.readLine();
}
}
catch (IOException ioe) {
ioe.printStackTrace();
}
catch (InterruptedException ie) {
ie.printStackTrace();
}
return value;
}
デスクトップなどの Android で再起動するにはどうすればよいですか? デフォルトの BASH またはその他のデフォルトの組み込み Android シェル スクリプトを使用できますか? または、コンパイルされていないスクリプトをその場で実行する他の方法がありますか?