I have created an standalone application in which i want that when the user clicks on the run button then the terminal should open and a particular command should be executed on the terminal. I am able to open the terminal successfully using the following code...
Process process = null;
try {
process = new ProcessBuilder("xterm").start();
} catch (IOException ex) {
System.err.println(ex);
}
The above code opens a terminal window but I am not able to execute any command on it. Can anyone tell me how to do that?
Try
new ProcessBuilder("xterm", "-e",
"/full/path/to/your/program").start()
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