How to execute the Windows CMD and perform a Ping??
807599Apr 3 2007 — edited Apr 9 2007This is the method i've been working to obtain the IP of a computer by making a Ping to the computer by the name it has!
Just as test, i work with a jTable.
tIdCompu is jText to show to the final user which computer name i am going to ping.
So, what i want to do, is that when i click a jButton, this that is on the tIdCompu to be perform in a CMD window. The same as when you go in Windows, and then you go to RUN, and the if i insert this code, i will perform the ping and also show me the CMD window. How can i make in my java program to execute the CMD action with the ping.
Thanks for your help,
Xavier Arroyo
-------------------- the code --------------------------------
public void obtnerValue(){
obActivo.setIpCod((String) jTable.getValueAt(1,0));
tIdCompu.setText("ping -t nameSubnet-"+obActivo.getIpCod());
// this part i don't know if it is correct or what do i have to change!
Runtime r=Runtime.getRuntime ( ) ;
try {
Process P=r.exec(tIdCompu.getText());
} catch (IOException ex) {
ex.printStackTrace();
}*/
}