public class App {
public static void main(String[] args) {
Process p = Runtime.getRuntime().exec("java -jar someOtherProgram.jar");
}
}
This effectively runs my other program. However, this program (App) does not close. It is still running (I can tell because it won't let me kill it in Eclipse). The only way to close this program is by killing the process that corresponds to someOtherProgram.jar
.
What I want is for my program, App, to run another Java program. And then kill itself.
You may want to use (on Linux)
nohup java -jar someOtherProgram.jar &
and in Windows
start /min java -jar someOtherProgram.jar
or
javaw -jar someOtherProgram.jar
Under Windows, I believe you need to use something like...
cmd /B start "" java -jar someOtherProgram.jar
Remember, if your path contains spaces, it will need to be quoted, for example
cmd /B start "" java -jar "path to your/program/someOtherProgram.jar"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With