check terminal if open
<p>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?</p>

<p>Here is my code for opening the terminal:</p>

<pre><code>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);
</code></pre>
