I've tryied to restart my Java Application with this code:
public static void restartApplication() throws URISyntaxException, IOException {
final File currentJar = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI());
/* is it a jar file? */
if(!currentJar.getName().endsWith(".jar"))
return;
/* Build command: java -jar application.jar */
final ProcessBuilder builder = new ProcessBuilder("java -Xmx512m -cp /opt/Nils.jar dev.keksstudios.core.Main");
builder.inheritIO();
builder.start();
System.exit(0);
}
When I type the command into my command panel it works totaly fine. So what is the Error here? Output
java.io.IOException: Cannot run program "java -Xmx512m -cp /opt/Nils.jar dev.keksstudios.core.Main": error=2, No such file or directory