I have a game, and I am going to enable auto-restarting features. It will happen every 24 hours, which is easy to make. However, the problem is, I don't know how to open run "run.sh" (which executes the Java Game Server).
The code is going to shut down everything first, and right before System.exit is called, it should open the run.sh in a new terminal. How would I do this?
This is the method I am currently using, but it's giving me this error.
public static boolean start() {
try {
List<String> command = new ArrayList<String>();
command.add("cd /root/Dropbox/[SALLESY] 742 Server");
command.add("java -Xmx1024m -Xss2m -Dsun.java2d.noddraw=true -XX:+DisableExplicitGC -XX:+AggressiveOpts -XX:+UseAdaptiveGCBoundary -XX:MaxGCPauseMillis=500 -XX:SurvivorRatio=16 -XX:+UseParallelGC -classpath bin:data/libs/* com.sallesy.Application");
ProcessBuilder builder = new ProcessBuilder(command);
Process proc = builder.start();
BufferedReader read = new BufferedReader(new InputStreamReader(
proc.getInputStream()));
try {
proc.waitFor();
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
while (read.ready()) {
System.out.println(read.readLine());
}
} catch (Exception e) {
System.out.println(e.getMessage());
return false;
}
return true;
}
Error:
sh script.sh
Cannot run program "cd /root/Dropbox/[SALLESY] 742 Server": error=2, No such file or directory
Could not start a new session...