I am using Ubuntu right now and I am able to open a terminal through Java code. But my problem is that when I close my program after the terminal has been opened, I will see a message saying that the terminal I opened has been closed?
Here is my code for opening the terminal:
String command = "gnome-terminal -x bash cd ~/Desktop";
String cmd[] = { "gnome-terminal", "-x", "bash", "-c", "sudo gedit ~/Desktop/wat.txt" };
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
You can call waitFor() on Process. The API says:
If you want your programm to continue function, then be sure to call your code in separate Thread.